Develop and Download Open Source Software

Browse Subversion Repository

Contents of /WinCS/WinCS.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 11 - (show annotations) (download) (as text)
Wed Feb 10 18:21:00 2010 UTC (14 years ago) by sho1get
File MIME type: text/x-c++src
File size: 1852 byte(s)


1 #include "stdafx.h"
2 #include "WinCS.h"
3 #include "WinCSDlg.h"
4
5 #ifdef _DEBUG
6 #define new DEBUG_NEW
7 #endif
8
9 BEGIN_MESSAGE_MAP(CWinCSApp, CWinApp)
10 ON_COMMAND(ID_HELP, &CWinApp::OnHelp)
11 END_MESSAGE_MAP()
12
13 //////////////////////////////////////////////////////////////////////////
14
15 CWinCSApp::CWinCSApp()
16 {
17 }
18
19 CWinCSApp theApp;
20
21 BOOL CWinCSApp::InitInstance()
22 {
23 INITCOMMONCONTROLSEX InitCtrls;
24 InitCtrls.dwSize = sizeof(InitCtrls);
25 InitCtrls.dwICC = ICC_WIN95_CLASSES;
26 InitCommonControlsEx(&InitCtrls);
27
28 // Double start prevention
29 if (!SingleStartup())
30 {
31 return FALSE;
32 }
33
34 // Set profile path
35 if (!SetProfilePath())
36 {
37 return FALSE;
38 }
39
40 // Initialize winsock(2.2)
41 if (!SocketXInitialize())
42 {
43 return FALSE;
44 }
45
46 CWinApp::InitInstance();
47
48 AfxEnableControlContainer();
49
50 CWinCSDlg dlg;
51 m_pMainWnd = &dlg;
52 dlg.DoModal();
53
54 return FALSE;
55 }
56
57 BOOL CWinCSApp::SetProfilePath()
58 {
59 TCHAR szModulePath[_MAX_PATH];
60 TCHAR szDrive[_MAX_DRIVE];
61 TCHAR szDir[_MAX_DIR];
62 TCHAR szFileName[_MAX_FNAME];
63 TCHAR szExt[_MAX_EXT];
64 int nRet;
65
66 nRet = ::GetModuleFileName(AfxGetInstanceHandle(), szModulePath, _MAX_PATH);
67
68 if (nRet == 0)
69 {
70 return FALSE;
71 }
72
73 if (m_pszProfileName != NULL)
74 {
75 free((void *)m_pszProfileName);
76 }
77
78 _tsplitpath_s(szModulePath,
79 szDrive, _MAX_DRIVE,
80 szDir, _MAX_DIR,
81 szFileName, _MAX_FNAME,
82 szExt, _MAX_EXT);
83
84 _tmakepath_s(szModulePath, _MAX_PATH,
85 szDrive, szDir, szFileName, _T("ini"));
86
87 m_pszProfileName = _tcsdup(szModulePath);
88
89 if (m_pszProfileName == NULL)
90 {
91 return FALSE;
92 }
93
94 return TRUE;
95 }
96
97 BOOL CWinCSApp::SingleStartup()
98 {
99 CString str;
100 str.LoadString(IDS_CONFIG_APPNAME);
101 return m_Startup.SingleStartup(str);
102 }
103
104 //////////////////////////////////////////////////////////////////////////

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26