void CopyFileList(CmyStringArray &astrSrc) { int i, nCount; BOOL bResult; char szPath[MAX_PATH], szFileNameSrc[MAX_PATH], szFileNameDst[MAX_PATH], szTmp[MAX_PATH]; LPSTR pszFileName; GetModuleFilePath (szPath, sizeof (szPath)); nCount = astrSrc.GetSize (); for (i = 0; i < nCount; i ++) { strcpy (szFileNameSrc, szPath); strcpy (szFileNameDst, szPath); strcat (szFileNameSrc, astrSrc[i]); strcat (szFileNameDst, "..\\"); strcat (szFileNameDst, astrSrc[i]); strcpy (szTmp, szFileNameDst); pszFileName = PathFindFileName (szTmp); if (pszFileName) { *pszFileName = 0; } AllCreateDirectory (szTmp); bResult = CopyFile (szFileNameSrc, szFileNameDst, FALSE); if (bResult) { /* コピーに成功したのでファイルを削除 */ DeleteFile (szFileNameSrc); } } }
void ExecuteLauncher(void) { BOOL bResult; char szPath[MAX_PATH], szTmp[MAX_PATH]; STARTUPINFO stStartupInfo; PROCESS_INFORMATION stProcInfo; CmyString strFileName; GetModuleFilePath (szPath, sizeof (szPath)); strFileName.Format ("%s..\\SboLaunch.exe", szPath); ZeroMemory (&stStartupInfo, sizeof (stStartupInfo)); ZeroMemory (&stProcInfo, sizeof (stProcInfo)); stStartupInfo.cb = sizeof (stStartupInfo); strcpy (szTmp, strFileName); bResult = CreateProcess (NULL, szTmp, NULL, NULL, FALSE, CREATE_DEFAULT_ERROR_MODE, NULL, szPath, &stStartupInfo, &stProcInfo); if (bResult == FALSE) { MessageBox (NULL, "SBOランチャーの起動に失敗しました", "エラー", MB_OK); goto Exit; } Exit: if (stProcInfo.hProcess) { CloseHandle (stProcInfo.hProcess); } if (stProcInfo.hThread) { CloseHandle (stProcInfo.hThread); } }
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { char szPath[MAX_PATH]; CmyStringArray astrFileList; GetModuleFilePath (szPath, sizeof (szPath)); QuitModule ("スクラップブックオンライン ランチャー"); ReadFileList (astrFileList); CopyFileList (astrFileList); ExecuteLauncher (); return 0; }
void CMakeFileListDlg::MakeHashList(void) { int i, nCount; char szPath[MAX_PATH], szHash[33]; DWORD dwFileSize; HANDLE hFile; CString strFileName, strTmp; CGetMD5File GetMD5; CStdioFile destFile; CArray <DWORD, DWORD> adwFileSize; GetModuleFilePath (szPath, sizeof (szPath)); nCount = m_astrFileList.GetSize (); for (i = 0; i < nCount; i ++) { strFileName.Format ("%s%s", szPath, m_astrFileList[i]); GetMD5.Init (); GetMD5.Update (strFileName); ZeroMemory (szHash, sizeof (szHash)); GetMD5.GetStr (szHash); if (strlen (szHash) <= 0) { continue; } m_astrHashList.Add (szHash); dwFileSize = 0; hFile = CreateFile (strFileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (hFile != INVALID_HANDLE_VALUE) { dwFileSize = GetFileSize (hFile, NULL); CloseHandle (hFile); } adwFileSize.Add (dwFileSize); } /* ハッシュリストを保存 */ strFileName.Format ("%sSBOHashList.txt", szPath); destFile.Open (strFileName, CFile::modeWrite | CFile::modeCreate, NULL); nCount = m_astrFileList.GetSize (); for (i = 0; i < nCount; i ++) { strTmp.Format ("%s,%u,%s\n", m_astrHashList[i], adwFileSize[i], m_astrFileList[i]); destFile.WriteString (strTmp); } destFile.Close (); }
void ReadFileList(CmyStringArray &astrDst) { int i, nCount; char szFileName[MAX_PATH]; CTextInput TextInput; CmyString strTmp; astrDst.RemoveAll (); GetModuleFilePath (szFileName, sizeof (szFileName)); strcat (szFileName, "FileList.txt"); TextInput.Create (szFileName); nCount = TextInput.GetLineCount (); for (i = 0; i < nCount; i ++) { strTmp = TextInput.ReadLine (); astrDst.Add (strTmp); } }
extern "C" __declspec(dllexport) bool GetExtensionEntry(unsigned int entryNo, IExtensionInfo& entry) { //Retrieve any required information from the version info table for our plugin std::wstring copyrightText; std::wstring commentsText; HMODULE moduleHandle = NULL; BOOL getModuleHandleExReturn = GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, (LPCWSTR)GetExtensionEntry, &moduleHandle); if(getModuleHandleExReturn != 0) { std::wstring modulePath = GetModuleFilePath(moduleHandle); GetModuleVersionInfoString(modulePath, VERSIONINFOPROPERTY_LEGALCOPYRIGHT, copyrightText); GetModuleVersionInfoString(modulePath, VERSIONINFOPROPERTY_COMMENTS, commentsText); } switch(entryNo) { case 0: entry.SetExtensionSettings(GetProcessorMenus, DeleteProcessorMenus, L"Processor.Menus", L"ProcessorMenus", 1, copyrightText, commentsText, true); return true; } return false; }
template<typename T> bool GetModuleDirPathImpl(ATL::CPathT<T>& dirPath) { GetModuleFilePath(dirPath.m_strPath); return !!dirPath.RemoveFileSpec(); }
int main(int argc, char* argv[]) { if (argc >= 2) g_sn = argv[1]; if (argc >= 3) g_sip = argv[2]; if (argc >= 4) g_port_req = atoi(argv[3]); if (argc >= 5) g_port_sub = atoi(argv[4]); std::cout << "Device SN: \t" << g_sn << std::endl; std::cout << "Server IP: \t" << g_sip << std::endl; std::cout << "Port_REQ: \t" << g_port_req << std::endl; std::cout << "Port_SUB: \t" << g_port_sub << std::endl; enet_initialize(); uv_loop_t *loop = uv_default_loop(); #ifndef RDC_LINUX_SYS std::string plugin_folder = GetModuleFilePath() + "\\plugins"; #else //std::string plugin_folder = GetModuleFilePath() + "/plugins"; std::string plugin_folder = "plugins"; #endif g_PluginLoader.Load(plugin_folder.c_str()); g_StreamMgr = new StreamMgr(loop); g_StreamMgr->Init(); void * ctx; ctx = zmq_ctx_new(); assert(ctx); int rc = create_req_socket(ctx); if (rc != 0) exit(EXIT_FAILURE); rc = Login(); if (rc != 0) { if (rc == -99) { printf("Device SN not authed!\n"); #ifndef RDC_LINUX_SYS Sleep(5000); #else sleep(5); #endif } exit(EXIT_FAILURE); } rc = create_sub_socket(ctx); if (rc != 0) exit(EXIT_FAILURE); uv_poll_t poll_sub; uv_os_sock_t socket; size_t len = sizeof(uv_os_sock_t); zmq_getsockopt(g_sub_socket, ZMQ_FD, &socket, &len); rc = uv_poll_init_socket(loop, &poll_sub, socket); assert(rc == 0); poll_sub.data = g_sub_socket; rc = uv_poll_start(&poll_sub, UV_READABLE, proccss_sub_msg); assert(rc == 0); uv_timer_t timer; rc = uv_timer_init(loop, &timer); assert(rc == 0); rc = uv_timer_start(&timer, Heartbeat_Timer, 1000, 20 * 1000); assert(rc == 0); //while (true) { // rc = uv_run(loop, UV_RUN_ONCE); //} uv_run(loop, UV_RUN_DEFAULT); rc = Logout(); uv_timer_stop(&timer); uv_poll_stop(&poll_sub); zmq_close(g_req_socket); zmq_close(g_sub_socket); zmq_ctx_term(ctx); g_StreamMgr->Close(); delete g_StreamMgr; g_PluginLoader.UnLoad(); enet_deinitialize(); #ifdef _DEBUG system("pause"); #endif return 0; }