首页 网络安全 安全学院 查看内容

C语言注册表自启动实现代码

2009-8-3 13:40 908 0

摘要: /* How add your application to startup! Author: K1u Site: k0h.org & k1u.org Disclaimer: I a...
关键词: HKEY newValue RegSetValueEx szPath Microsoft GetModuleFileNam CurrentVersion DWORD application reserved

/* How add your application to startup! Author: K1u Site: k0h.org & k1u.org Disclaimer: I am not responsible for how you use this. This is purely for educational purposes. BTW: If you wish to use this in your application give me a shout. */ #include <windows.h> int main(void) { /* Grab filename of process/exe using GetModuleFileName() function. */ TCHAR szPath[MAX_PATH]; GetModuleFileName(NULL, szPath, MAX_PATH); /* Create a New HKEY. */ HKEY newValue; /* Open Registry key. */ RegOpenKey(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\CurrentVersion\\Run", &newValue); /* Note use HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Run to add for the current user only. Now give a new value. Syntax for RegSetValueEx() function is LONG WINAPI RegSetValueEx( __in HKEY hKey, __in_opt LPCTSTR lpValueName, __reserved DWORD Reserved, __in DWORD dwType, __in_opt const BYTE* lpData, __in DWORD cbData ); More info at http://msdn2.microsoft.com/en-us/library/ms724923.aspx */ RegSetValueEx(newValue, "Name_Me_Please", 0, REG_SZ, (LPBYTE)szPath, sizeof(szPath)); /* Close the key. */ RegCloseKey(newValue); return 0; }
声明:文章版权归原作者所有 部分文章转自互联网 如有侵权请联系 [邮箱地址] 删除

路过

雷人

握手

鲜花

鸡蛋

最新评论

返回顶部