怎么样下面的代码运行时没有窗口呀??在线等
#include "stdafx.h"
#include <malloc.h>
#include <stdio.h>
#include "shlwapi.h"
#pragma comment (lib,"shlwapi.lib")
#include "c:\\program files\\microsoft sdk\\include\\winsvc.h"
#pragma comment (lib,"c:\\program files\\microsoft sdk\\lib\\Advapi32.lib")
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
SC_HANDLE scHandle = OpenSCManager(NULL,NULL,SC_MANAGER_ENUMERATE_SERVICE);
if(scHandle ==NULL)return 0;
ENUM_SERVICE_STATUS_PROCESS* pessp = NULL;
DWORD dwBytesRequired;
DWORD dwTotalServices;
DWORD ResumeHandle = 0 ;
HANDLE scHOutPut;
AllocConsole();
scHOutPut = GetStdHandle(STD_OUTPUT_HANDLE);
BOOL bRet = EnumServicesStatusEx(scHandle,SC_ENUM_PROCESS_INFO ,\
SERVICE_WIN32,SERVICE_STATE_ALL,(LPBYTE)pessp,0,&dwBytesRequired,\
&dwTotalServices,&ResumeHandle,NULL);
DWORD dwBufferSize = dwBytesRequired;
if(bRet == 0)
{
DWORD dwError = GetLastError();
if(ERROR_MORE_DATA == dwError)
{
pessp = (ENUM_SERVICE_STATUS_PROCESS*)malloc(dwBytesRequired);
bRet = EnumServicesStatusEx(scHandle,SC_ENUM_PROCESS_INFO ,\
SERVICE_WIN32,SERVICE_STATE_ALL,(LPBYTE)pessp,dwBufferSize,&dwBytesRequired,\
&dwTotalServices,&ResumeHandle,NULL);
if(bRet == 0)return 0;
TCHAR* szOutput = (TCHAR*)malloc(1024);
for(DWORD i = 0 ; i < dwTotalServices ; i++)
{
LPBYTE pbDesc = NULL;
DWORD dwBytesNeeded = 0;
SC_HANDLE hService = OpenService(scHandle,pessp[i].lpServiceName,SERVICE_QUERY_CONFIG);
if(NULL == hService)continue ;
QueryServiceConfig2(hService,SERVICE_CONFIG_DESCRIPTION,pbDesc,0,&dwBytesNeeded);
DWORD dwError = GetLastError();
if(dwError != ERROR_INSUFFICIENT_BUFFER)continue;
DWORD dwDescSize = dwBytesNeeded;
pbDesc = (LPBYTE)malloc(dwBytesNeeded);
ZeroMemory(pbDesc,dwBytesNeeded);
if(0 == QueryServiceConfig2(hService,SERVICE_CONFIG_DESCRIPTION,pbDesc,dwDescSize,&dwBytesNeeded))
{free(pbDesc);continue;}
ZeroMemory(szOutput,512);
StrCpy(szOutput,"\r\n");
StrCat(szOutput,pessp[i].lpServiceName);
StrCat(szOutput,",");
StrCat(szOutput,pessp[i].lpDisplayName);
StrCat(szOutput,",");
StrCat(szOutput,(const char*)(((SERVICE_DESCRIPTION*)pbDesc)->lpDescription));
WriteConsole(scHOutPut,szOutput,strlen(szOutput),NULL,0);
free(pbDesc);
CloseServiceHandle(hService);
}
CloseServiceHandle(scHandle);
free(szOutput);
free(pessp);
}
else return 0;
}
return 0;
}
[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课