home *** CD-ROM | disk | FTP | other *** search
- // CTaskModule Test.cpp : Defines the entry point for the application.
- //
-
- #include "stdafx.h"
-
- char * GetFileDirectory(const char *pProgramPath,char *pCurrentDirectory);
- void SetAppDirectoryAsCurrent(void);
-
- int APIENTRY WinMain(HINSTANCE hInstance,
- HINSTANCE hPrevInstance,
- LPSTR lpCmdLine,
- int nCmdShow)
- {
- // get the directory of the program
- SetAppDirectoryAsCurrent();
- // TODO: Place code here.
- CTaskModule *tmApp = new CTaskModule;
- tmApp->Init();
-
- MSG msg = {NULL};
- HACCEL hAccelTable = NULL;
-
- // Main message loop:
- while (GetMessage(&msg, NULL, 0, 0))
- {
- if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
- {
- TranslateMessage(&msg);
- DispatchMessage(&msg);
- }
- }
-
- delete tmApp;
- return msg.wParam;
- }
-
- char * GetFileDirectory(const char *pProgramPath,char *pCurrentDirectory)
- {// begin GetFileDirectory
- for(int i = lstrlen(pProgramPath)-1;i >= 0;i--)
- if(pProgramPath[i] == '\\')
- {// begin copy directory name into buffer
- lstrcpyn(pCurrentDirectory,pProgramPath,i+1);
- break;
- }// end copy directory name into buffer
- return pCurrentDirectory;
- }// end GetFileDirectory
-
- void SetAppDirectoryAsCurrent(void)
- {// begin SetAppDirectoryAsCurrent
- // get the directory of the program
- char pCurrentDirectory[MAX_PATH] = {NULL};
- char pProgramPath[MAX_PATH] = {NULL};
- GetModuleFileName(GetModuleHandle(NULL),pProgramPath,MAX_PATH-1);
- // turn into a directory
- GetFileDirectory(pProgramPath,pCurrentDirectory);
- // set the current directory to the one the program is running from
- SetCurrentDirectory(pCurrentDirectory);
- }// end SetAppDirectoryAsCurrent
-