MFC 설정 전원 켜기 시작

		      
                        HKEY hKey; 
			//         
			LPCTSTR lpRun = "Software\\Microsoft\\Windows\\CurrentVersion\\Run"; 
			//     Key 
			long lRet = RegOpenKeyEx(HKEY_LOCAL_MACHINE, lpRun, 0, KEY_WRITE, &hKey); 
			if(lRet == ERROR_SUCCESS) 
			{ 
				char pFileName[MAX_PATH] = {0}; 
				//           
				DWORD dwRet = GetModuleFileName(NULL, pFileName, MAX_PATH); 
				//     Key,     //    "test"       (    .exe)
				lRet = RegSetValueEx(hKey, "test", 0, REG_SZ, (BYTE *)pFileName, dwRet); 
				//      
				RegCloseKey(hKey); 
				if(lRet != ERROR_SUCCESS) 
				{ 
					AfxMessageBox("      ,          "); 
				} 
				else
				{
					AfxMessageBox("        "); 
				}
				isrun = 1;
			} 
      
				HKEY hKey; 
				//         
				LPCTSTR lpRun = "Software\\Microsoft\\Windows\\CurrentVersion\\Run"; 
				//     Key 
				long lRet = RegOpenKeyEx(HKEY_LOCAL_MACHINE, lpRun, 0, KEY_WRITE, &hKey); 
				if(lRet == ERROR_SUCCESS) 
				{ 
					char pFileName[MAX_PATH] = {0}; 
					//           
					DWORD dwRet = GetModuleFileName(NULL, pFileName, MAX_PATH); 
					//     Key,     //    "test"       (    .exe)
					lRet = RegDeleteValue(hKey, "test");
					//      
					RegCloseKey(hKey); 
					if(lRet != ERROR_SUCCESS) 
					{ 
						AfxMessageBox("      ,            "); 
					} 
					else{
						AfxMessageBox("        "); 
					}
			<SPAN style="WHITE-SPACE: pre">	</SPAN>}

참조 문구:http://blog.csdn.net/leesaiya/article/details/7398160

좋은 웹페이지 즐겨찾기