FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


modifiying the windows registry with the windows API - run





acromm
I make this function in c to add an entry in the windows registry, i hope it help. the objective is that my application or whatever run when windows initiate. Creates the key in the current user and in the local machine (for all users)

Code:

#include <windows.h>

//here i declare an array of characters with path of my application
char exec[] = "C:\\myapplication.exe";


void CreateKey(char *destino,char *namekey,char *keyvalue,int que)
{
HKEY key;   
if (que == 0) {
    RegCreateKey(HKEY_LOCAL_MACHINE,destino,&key);
    RegSetValueEx(key,namekey,0,REG_SZ,(BYTE *)keyvalue,lstrlen(keyvalue));
    RegCloseKey(key);
    } else if(que == 1) {
        RegCreateKey(HKEY_CURRENT_USER,destino,&key);
        RegSetValueEx(key,namekey,0,REG_SZ,(BYTE *)keyvalue,lstrlen(keyvalue));
        RegCloseKey(key);
    }   
}



in the Main of your application or wherever you want, call the function with:

Code:


CreaKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run","My Application Name",exec,0);



Switch the last parameter "1" for HKCU and "0" HKLM
Related topics
How Spyware Works!!!
I have a problem2........long startup time
751 Useful Windows XP Files
Spyware Doctor 3.2
Big guide to FREE programs!
Registry Tweak: Tooltip delay?
Microsoft blows it again... (Why NOT to use IE)
Mac or Windows -- the cool vs. the shizznik
Hide programs in "Software"
Need a program to edit startup programs
Windows Registry Permission
PROBLEM ABOUT HIDDING FOLDERS
FREE Powerfull Software for Windows
How can I pick Windows registry
Reply to topic    Frihost Forum Index -> Scripting -> Others

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.