Startup Program
Archives Forums/Win32 Discussion/Startup Program| 
 | ||
| How do I set up a program to start when windows starts? | 
| 
 | ||
| The easiest would be to put the program (or a link to it) into the startup folder. | 
| 
 | ||
| 
#include <windows.h>
BOOL SetStartupRegValue(const char *value, const char *valueData)
{
	HKEY hKey;   
	if (RegOpenKeyEx( HKEY_LOCAL_MACHINE,"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run",0, KEY_ALL_ACCESS, &hKey ) != ERROR_SUCCESS)
	{
		return(FALSE);
	}
	
	if (RegSetValueEx(hKey,value,0,REG_SZ,(LPBYTE) valueData,(strlen(valueData)+1))//"C:\\test.exe",13) != ERROR_SUCCESS)
	{
		RegCloseKey( hKey );
		return(FALSE);
	}
 
	RegCloseKey( hKey );
	return(TRUE);
}
A bit of old code there... shouldnt be too hard to max it up! :) | 
| 
 | ||
| As dabhand's code shows, you can also add the url to the "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run" key in the registry, once I'm finished with this current project I'll post a converted version. | 
| 
 | ||
| Uses this: http://www.blitzbasic.com/codearcs/codearcs.php?code=1991 Function SetStartupRegValue:Int(Value:String, ValueData:String) 
  Local temp:tregkey = OpenRegKey("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run") 
	
	If temp
		
		If temp.SetString(Value, valuedata) 
		   Return True
			
		EndIf
		
	EndIf
	
   Return False
   
End Function
Print SetStartupRegValue("testapp", "c:\test.exe") 
Input() 
End |