1 // gdipp_pre.cpp : main source file for gdipp_pre.exe
6 #include "gdipp_lib/helper.h"
7 #include "gdipp_pre/resource.h"
8 #include "gdipp_pre/MainDlg.h"
13 wchar_t config_path
[MAX_PATH
];
14 wchar_t *preview_text
= NULL
;
16 int Run(LPTSTR
/*lpstrCmdLine*/ = NULL
, int nCmdShow
= SW_SHOWDEFAULT
)
19 _Module
.AddMessageLoop(&theLoop
);
23 if (dlgMain
.Create(NULL
) == NULL
)
25 ATLTRACE(_T("Main dialog creation failed!\n"));
29 dlgMain
.ShowWindow(nCmdShow
);
31 int nRet
= theLoop
.Run();
33 _Module
.RemoveMessageLoop();
37 int WINAPI
_tWinMain(HINSTANCE hInstance
, HINSTANCE
/*hPrevInstance*/, LPTSTR lpstrCmdLine
, int nCmdShow
)
41 h_instance
= hInstance
;
43 b_ret
= gdipp::get_dir_file_path(hInstance
, L
"gdipp_config.xml", config_path
);
46 wchar_t preview_text_path
[MAX_PATH
];
47 b_ret
= gdipp::get_dir_file_path(hInstance
, L
"gdipp_preview.txt", preview_text_path
);
51 errno_t err
= _wfopen_s(&f
, preview_text_path
, L
"r, ccs=UNICODE");
54 fseek(f
, 0, SEEK_END
);
55 const long text_len
= ftell(f
);
58 preview_text
= new wchar_t[text_len
+ 1];
59 const size_t bytes_read
= fread(preview_text
, sizeof(wchar_t), text_len
, f
);
60 preview_text
[bytes_read
] = L
'\0';
65 HMODULE h_gdimm
= NULL
;
66 WCHAR gdimm_path
[MAX_PATH
];
69 b_ret
= gdipp::get_dir_file_path(NULL
, L
"gdimm_64.dll", gdimm_path
);
71 b_ret
= gdipp::get_dir_file_path(NULL
, L
"gdimm_32.dll", gdimm_path
);
74 // TODO: incomplete code
75 h_gdimm
= LoadLibraryW(gdimm_path
);
79 // If you are running on NT 4.0 or higher you can use the following call instead to
80 // make the EXE free threaded. This means that calls come in on a random RPC thread.
81 HRESULT hRes
= ::CoInitializeEx(NULL
, COINIT_MULTITHREADED
);
82 ATLASSERT(SUCCEEDED(hRes
));
84 // this resolves ATL window thunking problem when Microsoft Layer for Unicode (MSLU) is used
85 ::DefWindowProc(NULL
, 0, 0, 0L);
87 AtlInitCommonControls(ICC_BAR_CLASSES
); // add flags to support other controls
89 hRes
= _Module
.Init(NULL
, hInstance
);
90 ATLASSERT(SUCCEEDED(hRes
));
92 int nRet
= Run(lpstrCmdLine
, nCmdShow
);
100 if (preview_text
!= NULL
)
101 delete[] preview_text
;