| 0. 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 27. 28. 29. 30. 31. 32. 33. 34. 35. 36. 37. 38. 39. 40. 41. 42. 43. 44. 45. 46. 47. 48. 49. 50. 51. 52. 53. 54. 55. 56. 57. 58. 59. 60. 61. 62. 63. 64. 65. 66. 67. | /*
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;
} |