www.pudn.com > liuqudong.zip > TSInst.cpp


//====================================================================== 
// TSInst.cpp : Defines the entry point for the application. 
// 
// Written for the book Programming Windows CE 
// Copyright (C) 2003 Douglas Boling 
//====================================================================== 
 
#include "stdafx.h" 
//#include "service.h"                 // Service includes 
#include  
#include  
 
int WINAPI WinMain(	HINSTANCE hInstance, HINSTANCE hPrevInstance, 
				   LPTSTR lpCmdLine, int nCmdShow) { 
 
	HANDLE hDrv = RegisterService (TEXT("TCK"), 0,  
	                               TEXT("TickSrv.dll"), 0); 
	if (hDrv) { 
		printf ("Service loaded. %x\r\n", hDrv); 
 
		DWORD dwBytes; 
		ServiceIoControl (hDrv, IOCTL_SERVICE_INSTALL, 0, 0, 0, 0,  
						  &dwBytes, NULL); 
		printf ("Install complete\r\n"); 
		DeregisterService (hDrv); 
	} else  
		printf ("Service failed to load. rc %d\r\n", GetLastError()); 
	return 0; 
}