Auto Start Code :
Void cserverapp: setautorun ()
{
Hkey;
Char * szregpath = "SOFTWARE \ Microsoft \ Windows \ CurrentVersion \ Run ";
Long LRET;
// Open the Registry
LRET = regopenkeyex (HKEY_LOCAL_MACHINE, szregpath, 0,
Key_all_access, & hkey );
If (LRET! = Error_success)
{
Afxmessagebox ("An error occurred while enabling automatic Registry Startup! ");
Regclosekey (hkey );
Return;
}
// Obtain the path of the current file
Char szfilepath [max_path];
DWORD dwret;
Dwret = getmodulefilename (null, szfilepath, max_path );
If (dwret = 0)
{
Afxmessagebox ("failed to get the current file path! ");
Return;
}
// Add the current path to the Registry
LRET = regsetvalueex (hkey, "attendserver", 0, REG_SZ,
(Const byte *) & szfilepath, strlen (szfilepath) + 1 );
If (LRET! = Error_success)
{
Afxmessagebox ("An error occurred while writing to automatically start the registry! ");
Regclosekey (hkey );
Return;
}
Regclosekey (hkey );
}
Cancel the automatic run code:
Void cserverapp: cancelautorun ()
{
Hkey;
Char * szregpath = "SOFTWARE \ Microsoft \ Windows \ CurrentVersion \ Run ";
Long LRET;
// Open the Registry
LRET = regopenkeyex (HKEY_LOCAL_MACHINE, szregpath, 0,
Key_all_access, & hkey );
If (LRET! = Error_success)
{
Afxmessagebox ("An error occurred while enabling automatic Registry Startup! ");
Regclosekey (hkey );
Return;
}
LRET = regdeletevalue (hkey, "attendserver ");
If (LRET! = Error_success)
{
Afxmessagebox ("An error occurred while deleting the software during Automatic startup of registry settings! ");
Regclosekey (hkey );
Return;
}
Regclosekey (hkey );
}