반응형 전체 글304 프로세스 생성하기 -인자로 전달된 파일을 실행시킨다. #include void createPS(char* path){ STARTUPINFO si; PROCESS_INFORMATION pi; int state=0; si.cb=sizeof(STARTUPINFO); si.lpReserved=NULL; si.lpReserved2=NULL; si.cbReserved2=NULL; si.lpDesktop=NULL; si.lpTitle=NULL; si.dwFlags=STARTF_USESHOWWINDOW|STARTF_USESTDHANDLES; si.dwX=0; si.dwY=0; si.dwFillAttribute=0; si.wShowWindow=SW_HIDE; state=CreateProcess(NULL,path,NULL,NULL,TRUE.. 2011. 7. 4. 레지스트리 삭제하기 -RegDeleteValue로 레지스트리 값 제거가 가능하고 RegDeleteKey로 레지스트리 키 제거가 가능하다. #include int main(){ HKEY hkey; int result=0; RegOpenKey(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run",&hkey); //레지스트리 값 삭제 if(RegDeleteValue(hkey,"StartUPProgram") == ERROR_SUCCESS){ result++; } //레지스트리 키 삭제 if(RegDeleteKey(HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Control\\SafeBoot\\Minimal\\SVCWI.. 2011. 7. 4. 레지스트리 값 출력하기 -인자로 전달된 레지스트리 키의 하위 키와 값들을 출력한다. ex:)PrintReg(HKEY_LOCAL_MACHINE,"\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run"); //HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run 하위키와 값들을 출력한다. #include #include #define MAX_KEY_SIZE 512 #define MAX_VALUE_SIZE 512 BOOL PrintReg(HKEY root,char* key){ HKEY hkey; TCHAR key[MAX_KEY_SIZE]=""; TCHAR value[MAX_VALUE_SIZE]=""; DWORD keysize=MAX.. 2011. 7. 4. 윈도우 서비스 제거하기 -인자로 전달된 서비스명의 윈도우 서비스를 제거한다. #include #define BUFSIZE 512 void RemoveService(char* sc_name){ SC_HANDLE hManager; SC_HANDLE hService; SERVICE_STATUS sStat; char path[BUFSIZE]; hManager=OpenSCManager(NULL,NULL,SC_MANAGER_ALL_ACCESS); hService=OpenService(hManager,sc_name,SERVICE_ALL_ACCESS); if(hService){ //서비스 실행 중지 ControlService(hService,SERVICE_CONTROL_STOP,&sStat); while(QueryServiceStatus(h.. 2011. 7. 4. 파일 탐색하기 -인자로 전달된 디렉토리 경로로부터 파일을 탐색한다. ex:)SearchFile("C:\\*.*"); //C드라이브의 모든 파일을 탐색한다. #include #include #include #define BUFSIZE 512 void SearchFile(char* pPath){ struct _finddatai64_t c_file; intptr_t hFile; char dirPath[BUFSIZE]; char tempPath[BUFSIZE]; int i; //디렉토리 경로명만 추출하는 작업(현재 경로명에서 *.* 제거) strncpy(dirPath,pPath,BUFSIZE-1); i=strlen(dirPath)-4; dirPath[i]=0; //파일 탐색 시작 hFile=_findfirsti64(pPath.. 2011. 7. 4. 호스트 IP 주소 얻기 -인자로 전달한 문자열 포인터에 호스트 IP 주소를 저장한다. #include #include void GetHostIP(char* ip){ WORD wVersionRequested; WSADATA wsaData; char name[255]; PHOSTENT hostinfo; wVersionRequested = MAKEWORD(2,0); if(WSAStartup(wVersionRequested,&wsaData) == 0){ if(gethostname(name,sizeof(name)) ==0){ if((hostinfo = gethostbyname(name)) != NULL){ strcpy(ip,inet_ntoa(*(struct in_addr*)*hostinfo->h_addr_list)); } } } WSA.. 2011. 7. 4. 이전 1 ··· 25 26 27 28 29 30 31 ··· 51 다음 반응형