#include #include #include #include #include #ifdef __cplusplus #ifndef MESSAGEBOX #define MESSAGEBOX ::MessageBox #endif #else #ifndef MESSAGEBOX #define MESSAGEBOX MessageBox #endif #endif #define SFTC_3D_APP_SERVICE_REG "Software\\SFTC\\DEFORM-3D\\5.1" #define SFTC_3D_APP_SERVICE "sftc3win.exe" #define SFTC_3D_APP_SERVICE_PATH_REG_STRING "AppService" #define SFTC_3D_APP_SERVICE_NAME "DEFORM3DAppService" #define SFTC_3D_APP_SERVICE_DISPLAY_NAME "DEFORM 3D Application Service" int isFileExist(const char * szFileName); int main(int argc, char* argv[]) { static char* szCaption = "DEFORM - ERROR"; static char* szDebugCaption = "DEFORM - DEBUG"; char szBuffer[1024]; char szCommand[1024]; HKEY hKey; DWORD dwDisp, dwSize, dwType; char szPath[_MAX_PATH]; int nRetCode = 0; int nShowDebugMessage = 0; int nLen = 0; int i = 0; int nGetPathFromCommand = 0; char szPathFromCommand[1024]; char szCurrentFolder[_MAX_PATH]; SC_HANDLE Deform3dAppService,scm; for(i=0; i 0 ) { if ( szCommand[nLen-1] != '\\' ) { szCommand[nLen] = '\\'; szCommand[nLen+1] = '\0'; } } strcat(szCommand, SFTC_3D_APP_SERVICE); if ( nShowDebugMessage ) { sprintf(szBuffer, "The service prgram is : %s", szCommand); MESSAGEBOX(NULL, szBuffer, szDebugCaption, MB_OK | MB_TOPMOST); } nRetCode = isFileExist((const char *)szCommand); if ( !nRetCode ) { strcpy(szBuffer, "The DEFORM 3D application service program not found, exit.\n\n"); MESSAGEBOX(NULL, szBuffer, szCaption, MB_OK | MB_ICONSTOP | MB_TOPMOST); return 4; } Deform3dAppService=CreateService(scm, SFTC_3D_APP_SERVICE_NAME, SFTC_3D_APP_SERVICE_DISPLAY_NAME, SERVICE_ALL_ACCESS,SERVICE_WIN32_OWN_PROCESS |SERVICE_INTERACTIVE_PROCESS ,SERVICE_AUTO_START, SERVICE_ERROR_NORMAL, szCommand, /* "C:\\Michael\\tmp\\Debug\\TempService.exe", */ 0,0,0,0,0); if(!Deform3dAppService) { CloseServiceHandle(scm); strcpy(szBuffer, "Can not create Windows service, exit.\n\n"); MESSAGEBOX(NULL, szBuffer, szCaption, MB_OK | MB_ICONSTOP | MB_TOPMOST); return 5; } CloseServiceHandle(Deform3dAppService); CloseServiceHandle(scm); return 0; } int isFileExist(const char * szFileName) { FILE * f; if ( !szFileName ) { return 0; } f=fopen(szFileName, "r"); if (f==NULL) { return 0; } else { fclose(f); return 1; } } ========== This email message and any attachments are for the sole use of the intended recipients and may contain proprietary and/or confidential information which may be privileged or otherwise protected from disclosure. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipients, please contact the sender by reply email and destroy the original message and any copies of the message as well as any attachments to the original message. ========== This email message and any attachments are for the sole use of the intended recipients and may contain proprietary and/or confidential information which may be privileged or otherwise protected from disclosure. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipients, please contact the sender by reply email and destroy the original message and any copies of the message as well as any attachments to the original message.