void RenamePrinter(const std::tstring& currentPrinterName, const std::tstring& newPrinterName) { HANDLE printer = 0; PRINTER_INFO_2 *printerInfo = 0; DEVMODE *pDevMode = 0; try { // get the printer and it's info structure... PRINTER_DEFAULTS printerDefaults; ZeroMemory(&printerDefaults, sizeof(printerDefaults)); printerDefaults.DesiredAccess = PRINTER_ALL_ACCESS; BOOL result = OpenPrinter((LPTSTR)currentPrinterName.c_str(), &printer, &printerDefaults); if (!result || (0 == printer)) throw Workshare::Exception(_T("Failed to open printer.")); DWORD bufferSize = 0; SetLastError(0); result = GetPrinter(printer, 2, 0, 0, &bufferSize); if ((!result) && (GetLastError() != ERROR_INSUFFICIENT_BUFFER) || (bufferSize == 0)) throw Workshare::Exception(_T("Failed to get printer info buffer size.")); printerInfo = (PRINTER_INFO_2 *)GlobalAlloc(GPTR, bufferSize); if (0 == printerInfo) throw Workshare::System::SystemException(_T("Failed to allocate printer info buffer.")); result = GetPrinter(printer, 2, (LPBYTE)printerInfo, bufferSize, &bufferSize); if (!result) throw Workshare::Exception(_T("Failed to get printer info.")); // If GetPrinter didn't fill in the DEVMODE, try to get it by calling DocumentProperties... LONG lFlag; if (0 == printerInfo->pDevMode) { bufferSize = DocumentProperties(0, printer, (LPTSTR)currentPrinterName.c_str(), 0, 0, 0); if (bufferSize <= 0) throw Workshare::Exception(_T("Failed to get document properties buffer size.")); pDevMode = (DEVMODE *)GlobalAlloc(GPTR, bufferSize); if (0 == pDevMode) throw Workshare::System::SystemException(_T("Failed to allocate document properties buffer.")); lFlag = DocumentProperties(0, printer, (LPTSTR)currentPrinterName.c_str(), pDevMode, 0, DM_OUT_BUFFER); if (lFlag != IDOK || 0 == pDevMode) throw Workshare::Exception(_T("Failed to get document properties.")); printerInfo->pDevMode = pDevMode; } if (!(printerInfo->pDevMode->dmFields & DM_ORIENTATION)) throw Workshare::Exception(_T("Printer does not support the required name change.")); // Specify the new printer name... printerInfo->pPrinterName = (LPTSTR)newPrinterName.c_str() ; // Do not attempt to set security descriptor... printerInfo->pSecurityDescriptor = 0; lFlag = DocumentProperties(0, printer, (LPTSTR)currentPrinterName.c_str(), printerInfo->pDevMode, printerInfo->pDevMode, DM_IN_BUFFER | DM_OUT_BUFFER); if (IDOK != lFlag) throw Workshare::Exception(_T("Failed to update the devmode part of document properties.")); result = SetPrinter(printer, 2, (LPBYTE)printerInfo, 0); if (!result) throw Workshare::Exception(_T("Failed to update printer information.")); // Tell other apps that there was a change... SendMessageTimeout(HWND_BROADCAST, WM_DEVMODECHANGE, 0L, (LPARAM)(LPCTSTR)(LPTSTR)currentPrinterName.c_str(), SMTO_NORMAL, 1000, 0); return; } catch(...) { if (printerInfo) GlobalFree(printerInfo); if (printer) ClosePrinter(printer); if (pDevMode) GlobalFree(pDevMode); throw; } }
int CPostData::TBigDataPost() { //CString sTraceBuffer; CUrlCrack url; if (!url.Crack(m_strUrl.c_str())) return ERR_URLCRACKERROR; m_hInetSession = ::InternetOpen(MONEYHUB_USERAGENT, INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0); if (m_hInetSession == NULL) return ERR_NETWORKERROR; DWORD dwTimeOut = 10000; InternetSetOptionEx(m_hInetSession, INTERNET_OPTION_CONTROL_RECEIVE_TIMEOUT, &dwTimeOut, sizeof(DWORD), 0); InternetSetOptionEx(m_hInetSession, INTERNET_OPTION_CONTROL_SEND_TIMEOUT, &dwTimeOut, sizeof(DWORD), 0); InternetSetOptionEx(m_hInetSession, INTERNET_OPTION_SEND_TIMEOUT, &dwTimeOut, sizeof(DWORD), 0); InternetSetOptionEx(m_hInetSession, INTERNET_OPTION_RECEIVE_TIMEOUT, &dwTimeOut, sizeof(DWORD), 0); InternetSetOptionEx(m_hInetSession, INTERNET_OPTION_CONNECT_TIMEOUT, &dwTimeOut, sizeof(DWORD), 0); m_hInetConnection = ::InternetConnect(m_hInetSession, url.GetHostName(), url.GetPort(), NULL, NULL, INTERNET_SERVICE_HTTP, 0, (DWORD)this); if (m_hInetConnection == NULL) { CRecordProgram::GetInstance()->RecordWarnInfo(MY_PRO_NAME, MY_COMMON_ERROR, L"HttpSendRequestEx"); CloseHandles(); return ERR_NETWORKERROR; } LPCTSTR ppszAcceptTypes[2]; ppszAcceptTypes[0] = _T("*/*"); ppszAcceptTypes[1] = NULL; DWORD dwFlags = 0; if( url.GetPort() == 443 ) { dwFlags = INTERNET_FLAG_SECURE; //dwFlags = INTERNET_FLAG_NO_CACHE_WRITE | // INTERNET_FLAG_KEEP_CONNECTION | // INTERNET_FLAG_PRAGMA_NOCACHE | // INTERNET_FLAG_SECURE | // INTERNET_FLAG_IGNORE_CERT_CN_INVALID | // INTERNET_FLAG_IGNORE_CERT_DATE_INVALID | // SECURITY_FLAG_IGNORE_UNKNOWN_CA | // INTERNET_OPTION_SECURITY_FLAGS; } else if( url.GetPort() == 80 ) { //for HTTP //dwFlags = INTERNET_FLAG_NO_CACHE_WRITE | // INTERNET_FLAG_KEEP_CONNECTION | // INTERNET_FLAG_PRAGMA_NOCACHE ; dwFlags = INTERNET_FLAG_RELOAD | INTERNET_FLAG_KEEP_CONNECTION | INTERNET_FLAG_DONT_CACHE ; } //m_hInetFile = HttpOpenRequest(m_hInetConnection, _T("POST"), url.GetPath(), NULL, NULL, ppszAcceptTypes, dwFlags, (DWORD)this); m_hInetFile = HttpOpenRequest(m_hInetConnection, _T("POST"), url.GetPath(), NULL, NULL, ppszAcceptTypes, dwFlags, (DWORD)this); if (m_hInetFile == NULL) { CRecordProgram::GetInstance()->RecordWarnInfo(MY_PRO_NAME, MY_COMMON_ERROR, L"HttpSendRequestEx m_hInetFile"); CloseHandles(); return ERR_NETWORKERROR; } //if( url.GetPort() == 443 ) { DWORD dwBuffLen = sizeof(dwFlags); InternetQueryOption (m_hInetFile, INTERNET_OPTION_SECURITY_FLAGS, (LPVOID)&dwFlags, &dwBuffLen); dwFlags |= (SECURITY_FLAG_IGNORE_UNKNOWN_CA | SECURITY_FLAG_IGNORE_CERT_CN_INVALID); InternetSetOption (m_hInetFile, INTERNET_OPTION_SECURITY_FLAGS, &dwFlags, sizeof (dwFlags) ); } HttpAddRequestHeaders(m_hInetFile, _T("Content-Type: application/x-www-form-urlencoded\r\n"), -1, HTTP_ADDREQ_FLAG_ADD | HTTP_ADDREQ_FLAG_REPLACE); HttpAddRequestHeaders(m_hInetFile, _T("User-Agent: Mozilla/4.0 (compatible; MSIE 9.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET CLR 1.1.4322; .NET4.0C; .NET4.0E)\r\n"), -1, HTTP_ADDREQ_FLAG_ADD | HTTP_ADDREQ_FLAG_REPLACE); HttpAddRequestHeaders(m_hInetFile, _T("Accept-Language: zh-CN"), -1, HTTP_ADDREQ_FLAG_ADD | HTTP_ADDREQ_FLAG_REPLACE); return ERR_SUCCESS; }
int CPostData::TransferDataPost() { CUrlCrack url; if (!url.Crack(m_strUrl.c_str())) return ERR_URLCRACKERROR; m_hInetSession = ::InternetOpen(MONEYHUB_USERAGENT, INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0); if (m_hInetSession == NULL) return ERR_NETWORKERROR; //DWORD dwTimeOut = 60000; InternetSetOptionEx(m_hInetSession, INTERNET_OPTION_CONTROL_RECEIVE_TIMEOUT, &m_dwTimeOut, sizeof(DWORD), 0); InternetSetOptionEx(m_hInetSession, INTERNET_OPTION_CONTROL_SEND_TIMEOUT, &m_dwTimeOut, sizeof(DWORD), 0); InternetSetOptionEx(m_hInetSession, INTERNET_OPTION_SEND_TIMEOUT, &m_dwTimeOut, sizeof(DWORD), 0); InternetSetOptionEx(m_hInetSession, INTERNET_OPTION_RECEIVE_TIMEOUT, &m_dwTimeOut, sizeof(DWORD), 0); InternetSetOptionEx(m_hInetSession, INTERNET_OPTION_CONNECT_TIMEOUT, &m_dwTimeOut, sizeof(DWORD), 0); m_hInetConnection = ::InternetConnect(m_hInetSession, url.GetHostName(), url.GetPort(), NULL, NULL, INTERNET_SERVICE_HTTP, 0, (DWORD)this); if (m_hInetConnection == NULL) { CloseHandles(); return ERR_NETWORKERROR; } LPCTSTR ppszAcceptTypes[2]; ppszAcceptTypes[0] = _T("*/*"); ppszAcceptTypes[1] = NULL; DWORD dwFlags = 0; if(INTERNET_DEFAULT_HTTPS_PORT == url.GetPort()) { dwFlags = INTERNET_FLAG_SECURE; } else if(INTERNET_DEFAULT_HTTP_PORT == url.GetPort()) { dwFlags = INTERNET_FLAG_RELOAD | INTERNET_FLAG_DONT_CACHE | INTERNET_FLAG_KEEP_CONNECTION ; } m_hInetFile = HttpOpenRequest(m_hInetConnection, _T("POST"), url.GetPath(), NULL, NULL, ppszAcceptTypes, dwFlags, (DWORD)this); if (m_hInetFile == NULL) { CloseHandles(); return ERR_NETWORKERROR; } if(INTERNET_DEFAULT_HTTPS_PORT == url.GetPort()) { DWORD dwOptionFlags; DWORD dwBuffLen = sizeof(dwOptionFlags); InternetQueryOption (m_hInetFile, INTERNET_OPTION_SECURITY_FLAGS, (LPVOID)&dwOptionFlags, &dwBuffLen); dwOptionFlags |= (SECURITY_FLAG_IGNORE_UNKNOWN_CA | SECURITY_FLAG_IGNORE_CERT_CN_INVALID); InternetSetOption (m_hInetFile, INTERNET_OPTION_SECURITY_FLAGS, &dwOptionFlags, sizeof (dwOptionFlags) ); } HttpAddRequestHeaders(m_hInetFile, _T("Content-Type: application/x-www-form-urlencoded\r\n"), -1, HTTP_ADDREQ_FLAG_ADD | HTTP_ADDREQ_FLAG_REPLACE); HttpAddRequestHeaders(m_hInetFile, _T("User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET CLR 1.1.4322; .NET4.0C; .NET4.0E)\r\n"), -1, HTTP_ADDREQ_FLAG_ADD | HTTP_ADDREQ_FLAG_REPLACE); TCHAR szHeaders[1024]; _stprintf_s(szHeaders, _countof(szHeaders), _T("Moneyhubuid: %s\r\n"), m_strHWID.c_str()); HttpAddRequestHeaders(m_hInetFile, szHeaders, -1, HTTP_ADDREQ_FLAG_ADD | HTTP_ADDREQ_FLAG_REPLACE); BOOL bSend = ::HttpSendRequest(m_hInetFile, NULL, 0, m_lpPostData, m_dwPostDataLength); if (!bSend) { CloseHandles(); return ERR_NETWORKERROR; } CloseHandles(); return ERR_SUCCESS; }
void CToxProto::SetToxAvatar(std::tstring path) { FILE *hFile = _tfopen(path.c_str(), L"rb"); if (!hFile) { debugLogA(__FUNCTION__": failed to open avatar file"); return; } fseek(hFile, 0, SEEK_END); size_t length = ftell(hFile); rewind(hFile); if (length > TOX_MAX_AVATAR_SIZE) { fclose(hFile); debugLogA(__FUNCTION__": new avatar size is excessive"); return; } uint8_t *data = (uint8_t*)mir_alloc(length); if (fread(data, sizeof(uint8_t), length, hFile) != length) { fclose(hFile); debugLogA(__FUNCTION__": failed to read avatar file"); mir_free(data); return; } fclose(hFile); DBVARIANT dbv; uint8_t hash[TOX_HASH_LENGTH]; tox_hash(hash, data, TOX_HASH_LENGTH); if (!db_get(NULL, m_szModuleName, TOX_SETTINGS_AVATAR_HASH, &dbv)) { if (memcmp(hash, dbv.pbVal, TOX_HASH_LENGTH) == 0) { db_free(&dbv); mir_free(data); debugLogA(__FUNCTION__": new avatar is same with old"); return; } db_free(&dbv); } db_set_blob(NULL, m_szModuleName, TOX_SETTINGS_AVATAR_HASH, (void*)hash, TOX_HASH_LENGTH); if (IsOnline()) { for (MCONTACT hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) { if (GetContactStatus(hContact) == ID_STATUS_OFFLINE) continue; int32_t friendNumber = GetToxFriendNumber(hContact); if (friendNumber == UINT32_MAX) { mir_free(data); debugLogA(__FUNCTION__": failed to set new avatar"); return; } TOX_ERR_FILE_SEND error; uint32_t fileNumber = tox_file_send(tox, friendNumber, TOX_FILE_KIND_AVATAR, length, hash, NULL, 0, &error); if (error != TOX_ERR_FILE_SEND_OK) { mir_free(data); debugLogA(__FUNCTION__": failed to set new avatar"); return; } AvatarTransferParam *transfer = new AvatarTransferParam(friendNumber, fileNumber, NULL, length); transfer->pfts.flags |= PFTS_SENDING; memcpy(transfer->hash, hash, TOX_HASH_LENGTH); transfer->pfts.hContact = hContact; transfer->hFile = _tfopen(path.c_str(), L"rb"); transfers.Add(transfer); } } mir_free(data); }
ScriptComponent::ScriptComponent(const std::tstring& filename) { m_pScript = MyServiceLocator::GetInstance()->GetService<ResourceService>()->Load<LuaScript>(filename); auto slashIdx = filename.find_last_of(_T('/')); m_ShortFilename = TstringToString(filename.substr(slashIdx+1, filename.find_last_of(_T('.')) - slashIdx - 1)); }
BOOL GoogleLyricsProvider::ExtractLyrics(std::tstring& page) { UINT maxCharSeqLen = 0; LPCTSTR maxFirstSeqChar = 0; LPCTSTR maxLastSeqChar = 0; UINT curCharSeqLen = 0; LPCTSTR curFirstSeqChar = 0; LPCTSTR curChar = page.c_str(); BOOL bInTag = FALSE; BOOL bBRHasBeenFound = FALSE; std::tstring ansi; for (int pass = 0; pass < 2; pass++) { if (pass == 1) { //SecondPass if (maxCharSeqLen <= m_MinAllowedLyricsLen) return FALSE; curChar = maxFirstSeqChar; bInTag = FALSE; } while (*curChar != 0) { if (maxLastSeqChar <= curChar && pass == 1) { page = ansi; return TRUE; } switch (*curChar) { case '<': //ASSERT(bInTag == FALSE); bInTag = TRUE; if (_tcsnicmp(curChar, _T("<br"), 3) == 0 && curCharSeqLen > 0) { bBRHasBeenFound = TRUE; curCharSeqLen+=2; if (pass == 1) ansi += _T("\r\n"); //strcat(ansi, "\r\n"); } else { //Finished... if (curCharSeqLen > maxCharSeqLen) { maxCharSeqLen = curCharSeqLen; maxFirstSeqChar = curFirstSeqChar; maxLastSeqChar = curChar; } curCharSeqLen = 0; bBRHasBeenFound = FALSE; } break; case '>': //ASSERT(bInTag == TRUE); bInTag = FALSE; break; case 10: if (!bBRHasBeenFound && curCharSeqLen > 0)//This is a lonesome LF. He can t be here if it was CRLF (look 13) { curCharSeqLen+=2; if (pass==1) ansi += _T("\r\n"); //strcat(ansi, "\r\n"); } break; case 13: if (!bBRHasBeenFound && curCharSeqLen > 0) { curCharSeqLen+=2; if (pass==1) ansi += _T("\r\n"); if(*curChar == 10)//Handle the case that you get CR without LF following curChar++; } break; default: if (bInTag == FALSE) { if (curCharSeqLen == 0) curFirstSeqChar = curChar; if (pass == 1) ansi += *curChar; curCharSeqLen++; } } curChar++; } } return NULL; }
bool CToxProto::SetToxAvatar(std::tstring path, bool checkHash) { int length; uint8_t *data; FILE *hFile = _tfopen(path.c_str(), L"rb"); if (!hFile) { debugLogA("CToxProto::SetMyAvatar: failed to open avatar file"); return false; } fseek(hFile, 0, SEEK_END); length = ftell(hFile); rewind(hFile); if (length > TOX_AVATAR_MAX_DATA_LENGTH) { fclose(hFile); debugLogA("CToxProto::SetMyAvatar: new avatar size is excessive"); return false; } data = (uint8_t*)mir_alloc(length); size_t readed = fread(data, sizeof(uint8_t), length, hFile); if (readed != length) { fclose(hFile); debugLogA("CToxProto::SetMyAvatar: failed to read avatar file"); return false; } fclose(hFile); DBVARIANT dbv; uint8_t hash[TOX_HASH_LENGTH]; tox_hash(hash, data, TOX_HASH_LENGTH); if (checkHash && !db_get(NULL, m_szModuleName, TOX_SETTINGS_AVATAR_HASH, &dbv)) { if (memcmp(hash, dbv.pbVal, TOX_HASH_LENGTH) == 0) { db_free(&dbv); mir_free(data); debugLogA("CToxProto::SetMyAvatar: new avatar is same with old"); return false; } db_free(&dbv); } if (tox_set_avatar(tox, TOX_AVATAR_FORMAT_PNG, data, length) == TOX_ERROR) { mir_free(data); debugLogA("CToxProto::SetMyAvatar: failed to set new avatar"); return false; } mir_free(data); if (checkHash) { db_set_blob(NULL, m_szModuleName, TOX_SETTINGS_AVATAR_HASH, (void*)hash, TOX_HASH_LENGTH); } return true; }
bool ZipWrapper::AddFileToZip(const std::tstring& sFilename) { return m_zipArchive.AddNewFile(sFilename.c_str()); }
void MyLib::DelMediaPath(std::tstring &path) { m_pFileMonitor->DelDirectory(path.c_str()); mediaPaths.erase( find(mediaPaths.begin(),mediaPaths.end(),path) ); }
/*! Pluginページのメッセージ処理 @param hwndDlg ダイアログボックスのWindow Handlw @param uMsg メッセージ @param wParam パラメータ1 @param lParam パラメータ2 */ INT_PTR CPropPlugin::DispatchEvent( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam ) { NMHDR* pNMHDR; int idCtrl; WORD wNotifyCode; WORD wID; switch( uMsg ) { case WM_INITDIALOG: /* ダイアログデータの設定 Plugin */ InitDialog( hwndDlg ); SetData( hwndDlg ); // Modified by KEITA for WIN64 2003.9.6 ::SetWindowLongPtr( hwndDlg, DWLP_USER, lParam ); return TRUE; case WM_NOTIFY: idCtrl = (int)wParam; pNMHDR = (NMHDR*)lParam; switch( idCtrl ) { case IDC_PLUGINLIST: switch( pNMHDR->code ) { case LVN_ITEMCHANGED: { HWND hListView = ::GetDlgItem( hwndDlg, IDC_PLUGINLIST ); int sel = ListView_GetNextItem( hListView, -1, LVNI_SELECTED ); if( sel >= 0 ) { CPlugin* plugin = CPluginManager::getInstance()->GetPlugin(sel); if( plugin != NULL ) { ::SetWindowText( ::GetDlgItem( hwndDlg, IDC_LABEL_PLUGIN_Description ), to_tchar(plugin->m_sDescription.c_str()) ); ::SetWindowText( ::GetDlgItem( hwndDlg, IDC_LABEL_PLUGIN_Author ), to_tchar(plugin->m_sAuthor.c_str()) ); ::SetWindowText( ::GetDlgItem( hwndDlg, IDC_LABEL_PLUGIN_Version ), to_tchar(plugin->m_sVersion.c_str()) ); } else { ::SetWindowText( ::GetDlgItem( hwndDlg, IDC_LABEL_PLUGIN_Description ), _T("") ); ::SetWindowText( ::GetDlgItem( hwndDlg, IDC_LABEL_PLUGIN_Author ), _T("") ); ::SetWindowText( ::GetDlgItem( hwndDlg, IDC_LABEL_PLUGIN_Version ), _T("") ); } // 2010.08.21 明らかに使えないときはDisableにする EPluginState state = m_Common.m_sPlugin.m_PluginTable[sel].m_state; BOOL bEdit = (state != PLS_DELETED && state != PLS_NONE); ::EnableWindow( ::GetDlgItem( hwndDlg, IDC_PLUGIN_Remove ), bEdit ); ::EnableWindow( ::GetDlgItem( hwndDlg, IDC_PLUGIN_OPTION ), state == PLS_LOADED && plugin && plugin->m_options.size() > 0 ); ::EnableWindow( ::GetDlgItem( hwndDlg, IDC_PLUGIN_README ), (state == PLS_INSTALLED || state == PLS_UPDATED || state == PLS_LOADED || state == PLS_DELETED) && !GetReadMeFile(to_tchar(m_Common.m_sPlugin.m_PluginTable[sel].m_szName)).empty()); ::EnableWindow(::GetDlgItem(hwndDlg, IDC_PLUGIN_URL), state == PLS_LOADED && plugin && plugin->m_sUrl.size() > 0); } } break; case NM_DBLCLK: // リストビューへのダブルクリックで「プラグイン設定」を呼び出す if (::IsWindowEnabled(::GetDlgItem( hwndDlg, IDC_PLUGIN_OPTION ))) { DispatchEvent( hwndDlg, WM_COMMAND, MAKEWPARAM(IDC_PLUGIN_OPTION, BN_CLICKED), (LPARAM)::GetDlgItem( hwndDlg, IDC_PLUGIN_OPTION ) ); } break; } break; default: switch( pNMHDR->code ) { case PSN_HELP: OnHelp( hwndDlg, IDD_PROP_PLUGIN ); return TRUE; case PSN_KILLACTIVE: /* ダイアログデータの取得 Plugin */ GetData( hwndDlg ); return TRUE; case PSN_SETACTIVE: m_nPageNum = ID_PROPCOM_PAGENUM_PLUGIN; return TRUE; } break; } break; case WM_COMMAND: wNotifyCode = HIWORD(wParam); /* 通知コード */ wID = LOWORD(wParam); /* 項目ID、 コントロールID、 またはアクセラレータID */ switch( wNotifyCode ) { /* ボタン/チェックボックスがクリックされた */ case BN_CLICKED: switch( wID ) { case IDC_PLUGIN_SearchNew: // 新規プラグインを追加 GetData( hwndDlg ); CPluginManager::getInstance()->SearchNewPlugin( m_Common, hwndDlg ); if( m_bTrayProc ) { LoadPluginTemp(m_Common, *m_pcMenuDrawer); } SetData_LIST( hwndDlg ); //リストの再構築 break; case IDC_PLUGIN_INST_ZIP: // ZIPプラグインを追加 { static std::tstring sTrgDir; CDlgOpenFile cDlgOpenFile; TCHAR szPath[_MAX_PATH + 1]; _tcscpy( szPath, (sTrgDir.empty() ? CPluginManager::getInstance()->GetBaseDir().c_str() : sTrgDir.c_str())); // ファイルオープンダイアログの初期化 cDlgOpenFile.Create( G_AppInstance(), hwndDlg, _T("*.zip"), szPath ); if( cDlgOpenFile.DoModal_GetOpenFileName( szPath ) ) { GetData( hwndDlg ); CPluginManager::getInstance()->InstZipPlugin( m_Common, hwndDlg, szPath ); if( m_bTrayProc ) { LoadPluginTemp(m_Common, *m_pcMenuDrawer); } SetData_LIST( hwndDlg ); //リストの再構築 } // フォルダを記憶 TCHAR szFolder[_MAX_PATH + 1]; TCHAR szFname[_MAX_PATH + 1]; SplitPath_FolderAndFile(szPath, szFolder, szFname); sTrgDir = szFolder; } break; case IDC_CHECK_PluginEnable: // プラグインを有効にする EnablePluginPropInput( hwndDlg ); break; case IDC_PLUGIN_Remove: // プラグインを削除 { HWND hListView = ::GetDlgItem( hwndDlg, IDC_PLUGINLIST ); int sel = ListView_GetNextItem( hListView, -1, LVNI_SELECTED ); if( sel >= 0 ) { if( MYMESSAGEBOX( hwndDlg, MB_YESNO, GSTR_APPNAME, LS(STR_PROPCOMPLG_DELETE), m_Common.m_sPlugin.m_PluginTable[sel].m_szName ) == IDYES ) { CPluginManager::getInstance()->UninstallPlugin( m_Common, sel ); SetData_LIST( hwndDlg ); } } } break; case IDC_PLUGIN_OPTION: // プラグイン設定 // 2010/3/22 Uchi { HWND hListView = ::GetDlgItem( hwndDlg, IDC_PLUGINLIST ); int sel = ListView_GetNextItem( hListView, -1, LVNI_SELECTED ); if( sel >= 0 && m_Common.m_sPlugin.m_PluginTable[sel].m_state == PLS_LOADED ) { // 2010.08.21 プラグイン名(フォルダ名)の同一性の確認 CPlugin* plugin = CPluginManager::getInstance()->GetPlugin(sel); wstring sDirName = to_wchar(plugin->GetFolderName().c_str()); if( plugin && 0 == auto_stricmp(sDirName.c_str(), m_Common.m_sPlugin.m_PluginTable[sel].m_szName ) ) { CDlgPluginOption cDlgPluginOption; cDlgPluginOption.DoModal( ::GetModuleHandle(NULL), hwndDlg, this, sel ); } else { WarningMessage( hwndDlg, LS(STR_PROPCOMPLG_ERR1) ); } } } break; case IDC_PLUGIN_OpenFolder: // フォルダを開く { std::tstring sBaseDir = CPluginManager::getInstance()->GetBaseDir() + _T("."); if( ! IsDirectory(sBaseDir.c_str()) ) { if( ::CreateDirectory(sBaseDir.c_str(), NULL) == 0 ) { break; } } ::ShellExecute( NULL, _T("open"), sBaseDir.c_str(), NULL, NULL, SW_SHOW ); } break; case IDC_PLUGIN_README: // ReadMe表示 // 2011/11/2 Uchi { HWND hListView = ::GetDlgItem( hwndDlg, IDC_PLUGINLIST ); int sel = ListView_GetNextItem( hListView, -1, LVNI_SELECTED ); std::tstring sName = to_tchar(m_Common.m_sPlugin.m_PluginTable[sel].m_szName); // 個別フォルダ名 std::tstring sReadMeName = GetReadMeFile(sName); if (!sReadMeName.empty()) { if (!BrowseReadMe(sReadMeName)) { WarningMessage( hwndDlg, LS(STR_PROPCOMPLG_ERR2) ); } } else { WarningMessage( hwndDlg, LS(STR_PROPCOMPLG_ERR3) ); } } break; case IDC_PLUGIN_URL: { HWND hListView = ::GetDlgItem(hwndDlg, IDC_PLUGINLIST); int sel = ListView_GetNextItem(hListView, -1, LVNI_SELECTED); if (sel >= 0) { CPlugin* plugin = CPluginManager::getInstance()->GetPlugin(sel); if (plugin != NULL) { ::ShellExecute(NULL, _T("Open"), to_tchar(plugin->m_sUrl.c_str()), NULL, NULL, SW_SHOW); } } } break; } break; case CBN_DROPDOWN: //switch( wID ){ //default: // break; //} break; /* CBN_DROPDOWN */ case EN_KILLFOCUS: //switch( wID ){ //default: // break; //} break; } break; /* WM_COMMAND */ //@@@ 2001.02.04 Start by MIK: Popup Help case WM_HELP: { HELPINFO *p = (HELPINFO *)lParam; MyWinHelp( (HWND)p->hItemHandle, HELP_WM_HELP, (ULONG_PTR)(LPVOID)p_helpids ); // 2006.10.10 ryoji MyWinHelpに変更に変更 } return TRUE; /*NOTREACHED*/ //break; //@@@ 2001.02.04 End //@@@ 2001.12.22 Start by MIK: Context Menu Help //Context Menu case WM_CONTEXTMENU: MyWinHelp( hwndDlg, HELP_CONTEXTMENU, (ULONG_PTR)(LPVOID)p_helpids ); // 2006.10.10 ryoji MyWinHelpに変更に変更 return TRUE; //@@@ 2001.12.22 End } return FALSE; }
//TODO: Another plea for a solid string class std::wstring Convert(const std::tstring& s) { USES_CONVERSION; return(T2W(const_cast<TCHAR*>(s.c_str()))); }