Jump to content

Coding challenge


snakey

Recommended Posts

  • Replies 237
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Posted Images

  • 2 months later...

i think a new thread would be good too, i think i suggested that a long time ago.

the game sounds, ok, but needs more detail, and the idea of making extra challenges like certain about of lines, or a limit of size and stuff would be fun.

Link to comment
Share on other sites

  • 2 weeks later...

Code Challenge - Starts 8/11/09 - Ends 8/31/09

Write a program in C that changes the desktop background of a Windows XP machine.

Requirements:

1 - Must take command line argument for file path of image (i.e. C:\image.bmp)

2 - Program must not crash on invalid input

3 - Changes must take affect, (at the very latest) on reboot.

Winner is the person who's program uses the fewest characters (white space doesn't count).

Hint

Link to comment
Share on other sites

Ok, i 'm done with the coding. Should i upload the executable and put a link in here or is there any other procedure?

Just post source code, no bins.

Link to comment
Share on other sites

Well, its one of the options. But it took me less than 30min to code this one so, if someone gets the code, he can alter it in no-time. So ether we post the bins and the code when the voting is over, or the one that sets the challenge takes the code and posts it for voting. ^_^

Link to comment
Share on other sites

Well, its one of the options. But it took me less than 30min to code this one so, if someone gets the code, he can alter it in no-time. So ether we post the bins and the code when the voting is over, or the one that sets the challenge takes the code and posts it for voting. ^_^

Agreed, post screen shots, source code on the last day. I'd still prefer no bins.

Link to comment
Share on other sites

I already have an Idea for the next challenge which should be doable in all languages.

Oh and maybe at the end of the contest the winner of the challenge could post their compiled piece of software cuz not everbody has a c++ compiler or an assembler or knows how to use them.

Link to comment
Share on other sites

-.-' i suck ass at C, the concept is easy enough and i can do it / have it working perfect, just not in C. So if no one else has interest bar corcrash, can the source be posted and we move on to an open language contest with no silly restraints like limited lines / characters which is just bad programming.

Your taught to worry about complexity, and mem managment, not file size of your source.

Link to comment
Share on other sites

#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include <string.h>

char image[255];
FILE *file;

int main(int argc, char *argv[])
{
    HKEY hKey;
    
    strcpy(image, argv[1]);
            
    if((file = fopen(image, "r"))==NULL){
             printf("The specified file doesn't exist!");
             }
    else
    {
        if(RegOpenKeyEx(HKEY_CURRENT_USER, "Control Panel\\Desktop", 0, KEY_SET_VALUE, &hKey) != ERROR_SUCCESS){
                                       printf("Couldn't open registry!");
                                       }
        else
        {
        RegSetValueEx(hKey, "Wallpaper", 0, REG_SZ, (const unsigned char*)image, sizeof(image));
        RegCloseKey(hKey);
        }
    }
    fclose(file);
    system("RUNDLL32.EXE user32.dll,UpdatePerUserSystemParameters");
    printf("Check your background, it should be changed!");
  
  system("PAUSE");    
  return 0;
}

There, this is the code, uncommented but if someone doesn't understand something feel free to ask. The program has only one bug, it crashes when no argument is given. So the usage goes like this, "nameofbin nameofimage", the image has to be a 24-bit BMP (don't ask why, its windows) u wanted the program compact so no place for conversion algorithms. I hope u can get it to work, if not ask and ill try to fix that. ^_^

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.

×
×
  • Create New...