C++ WinAPI Startup

Dell / OPTIPLEX
April 13, 2009 at 20:32:35
Specs: Linux i686, 1.8ghz/ 512 mb
I am making a program to monitor my system and upload logs to an ftp server everyday at 1200, I have it all down pat except how to make it auto run if say: the power goes off? It will be on a windows vista AND a windows xp pc, I could do the thing with the startup folder, but I hate bloating that up, in fact I hate bloat quite a bit. Can anyone tell me how to use the following code snippet to run my program on bootup?

It is C++ and as you can see is not any where near being finished. I have the proper headers included


LONG WINAPI RegCreateKeyEx( HKEY_LOCAL_MACHINE,Software\Microsoft\Windows\CurrentVersion\Run , 0, NULL, REG_OPTION_NON_VOLATILE 0x00000000L, KEY_ALL_ACCESS (0xF003F), NULL, REG_CREATED_NEW_KEY 0x00000001L );

LONG WINAPI RegSetValueEx( HKEY_LOCAL_MACHINE,
  __in_opt    LPCTSTR lpValueName, 0,
  __in        DWORD dwType,
  __in_opt    const BYTE *lpData,
  __in        DWORD cbData
);

RegCloseKey();

I only Batch if possible, 2000 more lines of code, oh well.


See More: C++ WinAPI Startup

Report •


#1
April 14, 2009 at 08:22:47
You could try using the Task Scheduler; that's what it's there for, after all. MSDN even has an example.

Report •

#2
April 14, 2009 at 08:25:08
heh,i cant get winapi working, and you point me to something longer? -_-'

I only Batch if possible, 2000 more lines of code, oh well.


Report •

#3
April 14, 2009 at 08:32:18
Yes, because you need to learn the C++ style, which is incomparably different to batch script style. If it weren't for ulterior motives, I wouldn't have any motivation at all.

Add that to the fact that I provided a working example, and you can have it working by the end of the day.


Report •

Related Solutions

#4
April 14, 2009 at 08:36:44
sure: If i wasn't trying to keep this short and sweet -_- thats like 100 lines of code instead of three needed with the WinApi,

ps. I havent used batch in like two years or so, its just my name on CN

I only Batch if possible, 2000 more lines of code, oh well.


Report •

#5
April 14, 2009 at 08:44:24
Bah, two-thirds of it is error checking, and like, one-sixth of it is comments. It also acquires permissions, so it should work on UAC enabled Vista.

Also, I saw your previous piece of "c++" code.


Report •

#6
April 14, 2009 at 10:10:29
lol i know that was horrible right? That was my first piece of code in C++, i never said i had been doing C++ for the past few years lol, i just said i hadnt used batch in that long :p

and this one will only have to run once, I am pretty sure i can click on the UAC popup one or *six* times :p

I only Batch if possible, 2000 more lines of code, oh well.


Report •


Ask Question