unsigned _stdcall even_thread_cs(void *p) { for( int i = 0 ; i < MAX ; i++ ) { EnterCriticalSection(&cs); if( shared_value % 2 == 0 ) { printf("\n%d", i); wchar_t buffer[256]; wsprintfW(buffer, L"%d", i); ::MessageBox(NULL, buffer , L"Even Dlg title", MB_OK); } LeaveCriticalSection(&cs); } return 0; }
/* this is called from the WM_SHOWWINDOW handlers of each tab page. * * it's a nasty hack, necessary because the property sheet insists on resetting the window title * to the title of the tab, which is utterly useless. dropping the property sheet is on the todo list. */ void set_window_title(HWND dialog) { WCHAR newtitle[256]; /* update the window title */ if (current_app) { WCHAR apptitle[256]; LoadStringW (GetModuleHandle(NULL), IDS_WINECFG_TITLE_APP, apptitle, sizeof(apptitle)/sizeof(apptitle[0])); wsprintfW (newtitle, apptitle, current_app); } else { LoadStringW (GetModuleHandle(NULL), IDS_WINECFG_TITLE, newtitle, sizeof(newtitle)/sizeof(newtitle[0])); } WINE_TRACE("setting title to %s\n", wine_dbgstr_w (newtitle)); SendMessageW (GetParent(dialog), PSM_SETTITLEW, 0, (LPARAM) newtitle); }
HRESULT CMediaViewer::AddToRot(IUnknown *pUnkGraph, DWORD *pdwRegister) const { // デバッグ用 IMoniker * pMoniker; IRunningObjectTable *pROT; if(FAILED(::GetRunningObjectTable(0, &pROT)))return E_FAIL; WCHAR wsz[256]; wsprintfW(wsz, L"FilterGraph %08p pid %08x", (DWORD_PTR)pUnkGraph, ::GetCurrentProcessId()); HRESULT hr = ::CreateItemMoniker(L"!", wsz, &pMoniker); if(SUCCEEDED(hr)){ hr = pROT->Register(0, pUnkGraph, pMoniker, pdwRegister); pMoniker->Release(); } pROT->Release(); return hr; }
VOID WINAPI GenMD5Code(const WCHAR* FileName, wstring& OutHex) { BYTE OutBuffer[16] = { 0 }; MD5Context Context; MD5Init(&Context); MD5Update(&Context, (BYTE*)FileName, lstrlenW(FileName) * 2); MD5Final(OutBuffer, &Context); WCHAR OutTemp[3] = { 0 }; for (ULONG32 i = 0; i < 16; i++) { wsprintfW(OutTemp, L"%x", (OutBuffer[i] & 0xF0) >> 4); OutHex += OutTemp; RtlZeroMemory(OutTemp, 0, sizeof(wchar_t)* 3); wsprintfW(OutTemp, L"%x", OutBuffer[i] & 0x0F); OutHex += OutTemp; RtlZeroMemory(OutTemp, 0, sizeof(wchar_t)* 3); } }
/********************************************************************** * COMCAT_GetCategoryDesc */ static HRESULT COMCAT_GetCategoryDesc(HKEY key, LCID lcid, PWCHAR pszDesc, ULONG buf_wchars) { static const WCHAR fmt[] = { '%', 'l', 'X', 0 }; WCHAR valname[5]; HRESULT res; DWORD type, size = (buf_wchars - 1) * sizeof(WCHAR); if (pszDesc == NULL) return E_INVALIDARG; /* FIXME: lcid comparisons are more complex than this! */ wsprintfW(valname, fmt, lcid); res = RegQueryValueExW(key, valname, 0, &type, (LPBYTE)pszDesc, &size); if (res != ERROR_SUCCESS || type != REG_SZ) { FIXME("Simplified lcid comparison\n"); return CAT_E_NODESCRIPTION; } pszDesc[size / sizeof(WCHAR)] = 0; return S_OK; }
HRESULT e3d_get_process_key(BYTE * key) { int len = 4; wchar_t pid[100]; wsprintfW(pid, L"%d", GetCurrentProcessId()); HKEY hkey = NULL; int ret = RegOpenKeyExW(HKEY_CURRENT_USER, e3d_soft_key,0,STANDARD_RIGHTS_REQUIRED |KEY_READ , &hkey); if (ret != ERROR_SUCCESS || hkey == NULL) return E_FAIL; unsigned char * p_key_got = NULL; RegQueryValueExW(hkey, pid, 0, NULL, (LPBYTE)&p_key_got, (LPDWORD)&len); RegCloseKey(hkey); if (p_key_got) memcpy(key, p_key_got, 32); return e3d_del_process_key(); }
// Adds a DirectShow filter graph to the Running Object Table, // allowing GraphEdit to "spy" on a remote filter graph. HRESULT CBDAFilterGraph::AddGraphToRot( IUnknown *pUnkGraph, DWORD *pdwRegister ) { CComPtr <IMoniker> pMoniker; CComPtr <IRunningObjectTable> pROT; WCHAR wsz[128]; HRESULT hr; if (FAILED(GetRunningObjectTable(0, &pROT))) return E_FAIL; wsprintfW(wsz, L"FilterGraph %08x pid %08x", (DWORD_PTR)pUnkGraph, GetCurrentProcessId()); hr = CreateItemMoniker(L"!", wsz, &pMoniker); if (SUCCEEDED(hr)) hr = pROT->Register(0, pUnkGraph, pMoniker, pdwRegister); return hr; }
std::string excelreader::GetDataAsString(int row, int col) { if (row < 0 || col < 0) throw ExcelException("Cell not exit"); WCHAR szTmp[6]; wsprintfW(szTmp, L"%i", row); std::wstring sTmp = GetColumnName(col) + szTmp + L":" + GetColumnName(col) + szTmp; _variant_t parm(sTmp.c_str()); _variant_t result; AutoWrap(DISPATCH_PROPERTYGET, &result, pXlSheet, L"Range", 1, (VARIANT)parm); _variant_t data; AutoWrap(DISPATCH_PROPERTYGET, &data, result.pdispVal, L"Value", 0); //if (VariantChangeType(&data, &data, 0, VT_BSTR) != S_OK) { // throw ExcelException("Cannot convert data to string"); //} //CW2A ansiBuffer((_bstr_t)data); //CT2A cc((_bstr_t)data); //std::string s(cc); return tostr(data); }
static LRESULT IPADDRESS_SetAddress (IPADDRESS_INFO *infoPtr, DWORD ip_address) { WCHAR buf[20]; static const WCHAR fmt[] = { '%', 'd', 0 }; int i; TRACE("\n"); for (i = 3; i >= 0; i--) { IPPART_INFO* part = &infoPtr->Part[i]; int value = ip_address & 0xff; if ( (value >= part->LowerLimit) && (value <= part->UpperLimit) ) { wsprintfW (buf, fmt, value); SetWindowTextW (part->EditHwnd, buf); IPADDRESS_Notify (infoPtr, EN_CHANGE); } ip_address >>= 8; } return TRUE; }
/****************************************************************************** * GetObjectInfo : get information about a device object such as a button * or axis */ static HRESULT WINAPI SysMouseWImpl_GetObjectInfo(LPDIRECTINPUTDEVICE8W iface, LPDIDEVICEOBJECTINSTANCEW pdidoi, DWORD dwObj, DWORD dwHow) { static const WCHAR x_axisW[] = {'X','-','A','x','i','s',0}; static const WCHAR y_axisW[] = {'Y','-','A','x','i','s',0}; static const WCHAR wheelW[] = {'W','h','e','e','l',0}; static const WCHAR buttonW[] = {'B','u','t','t','o','n',' ','%','d',0}; HRESULT res; res = IDirectInputDevice2WImpl_GetObjectInfo(iface, pdidoi, dwObj, dwHow); if (res != DI_OK) return res; if (IsEqualGUID(&pdidoi->guidType, &GUID_XAxis)) strcpyW(pdidoi->tszName, x_axisW); else if (IsEqualGUID(&pdidoi->guidType, &GUID_YAxis)) strcpyW(pdidoi->tszName, y_axisW); else if (IsEqualGUID(&pdidoi->guidType, &GUID_ZAxis)) strcpyW(pdidoi->tszName, wheelW); else if (pdidoi->dwType & DIDFT_BUTTON) wsprintfW(pdidoi->tszName, buttonW, DIDFT_GETINSTANCE(pdidoi->dwType) - 3); _dump_OBJECTINSTANCEW(pdidoi); return res; }
/*********************************************************************** * UPDOWN_SetBuddyInt * Tries to set the pos to the buddy window based on current pos * returns: * TRUE - if it set the caption of the buddy successfully * FALSE - if an error occurred */ static BOOL UPDOWN_SetBuddyInt (const UPDOWN_INFO *infoPtr) { WCHAR fmt[3] = { '%', 'd', '\0' }; WCHAR txt[20]; int len; if (!((infoPtr->dwStyle & UDS_SETBUDDYINT) && IsWindow(infoPtr->Buddy))) return FALSE; TRACE("set new value(%d) to buddy.\n", infoPtr->CurVal); /*if the buddy is a list window, we must set curr index */ if (UPDOWN_IsBuddyListbox(infoPtr)) { return SendMessageW(infoPtr->Buddy, LB_SETCURSEL, infoPtr->CurVal, 0) != LB_ERR; } /* Regular window, so set caption to the number */ if (infoPtr->Base == 16) fmt[1] = 'X'; len = wsprintfW(txt, fmt, infoPtr->CurVal); /* Do thousands separation if necessary */ if (!(infoPtr->dwStyle & UDS_NOTHOUSANDS) && (len > 3)) { WCHAR tmp[COUNT_OF(txt)], *src = tmp, *dst = txt; WCHAR sep = UPDOWN_GetThousandSep(); int start = len % 3; memcpy(tmp, txt, sizeof(txt)); if (start == 0) start = 3; dst += start; src += start; for (len=0; *src; len++) { if (len % 3 == 0) *dst++ = sep; *dst++ = *src++; } *dst = 0; } return SetWindowTextW(infoPtr->Buddy, txt); }
HRESULT AddGraphToRot(IUnknown *pUnkGraph, DWORD *pdwRegister) { IMoniker * pMoniker; IRunningObjectTable *pROT; WCHAR wsz[128]; HRESULT hr; if (FAILED(GetRunningObjectTable(0, &pROT))) { return E_FAIL; } wsprintfW(wsz, L"FilterGraph %08x pid %08x", (DWORD_PTR)pUnkGraph, GetCurrentProcessId()); hr = CreateItemMoniker(L"!", wsz, &pMoniker); if (SUCCEEDED(hr)) { hr = pROT->Register(0, pUnkGraph, pMoniker, pdwRegister); pMoniker->Release(); } pROT->Release(); return hr; }
void SDesktopDock::OnLButtonUp(UINT nFlags, CPoint point) { for (int i=0; i<MAX_COUNT; i++) { if (m_RTRect[i].PtInRect(point)) { TCHAR chTemp[MAX_PATH]=_T(""); wsprintfW(chTemp,TEXT("索引===%d号"), i); SMessageBox(NULL,chTemp,L"多点WIFI",MB_OK); if (i==0){ ShellExecute(NULL, L"open",L"http://www.wf06.com", NULL, NULL, SW_SHOWNORMAL); }else if (i==1){ ShellExecute(NULL, L"open",L"http://www.sk53.com", NULL, NULL, SW_SHOWNORMAL); } return ; } } }
// Function name : CVMR9Graph::AddToRot // Description : let the graph instance be accessible from graphedit // Return type : HRESULT // Argument : IUnknown *pUnkGraph // Argument : DWORD *pdwRegister HRESULT CVMR9Graph::AddToRot(IUnknown *pUnkGraph) { if (pUnkGraph == NULL) { return E_INVALIDARG; } IMoniker * pMoniker; IRunningObjectTable *pROT; if (FAILED(GetRunningObjectTable(0, &pROT))) { return E_FAIL; } WCHAR wsz[256]; wsprintfW(wsz, L"FilterGraph %08x pid %08x", (DWORD_PTR)pUnkGraph, GetCurrentProcessId()); HRESULT hr = CreateItemMoniker(L"!", wsz, &pMoniker); if (SUCCEEDED(hr)) { hr = pROT->Register(0, pUnkGraph, pMoniker, &m_dwRotId); pMoniker->Release(); } pROT->Release(); return hr; }
/* * ucmWusaExtractPackage * * Purpose: * * Extract cab to protected directory using wusa. * */ BOOL ucmWusaExtractPackage( LPWSTR lpCommandLine ) { BOOL bResult = FALSE; WCHAR szMsuFileName[MAX_PATH * 2]; WCHAR szCmd[MAX_PATH * 4]; RtlSecureZeroMemory(szMsuFileName, sizeof(szMsuFileName)); _strcpy(szMsuFileName, g_ctx.szTempDirectory); _strcat(szMsuFileName, ELLOCNAK_MSU); //extract msu data to target directory RtlSecureZeroMemory(szCmd, sizeof(szCmd)); wsprintfW(szCmd, lpCommandLine, szMsuFileName); bResult = supRunProcess(L"cmd.exe", szCmd); if (szMsuFileName[0] != 0) { DeleteFileW(szMsuFileName); } return bResult; }
BOOL CreateValue(HWND hwnd, HKEY hKeyRoot, LPCWSTR keyPath, DWORD valueType, LPWSTR valueName) { LONG lRet = ERROR_SUCCESS; WCHAR newValue[256]; DWORD valueDword = 0; BOOL result = FALSE; int valueNum; HKEY hKey; lRet = RegOpenKeyExW(hKeyRoot, keyPath, 0, KEY_READ | KEY_SET_VALUE, &hKey); if (lRet != ERROR_SUCCESS) { error_code_messagebox(hwnd, lRet); return FALSE; } if (!LoadStringW(GetModuleHandleW(0), IDS_NEWVALUE, newValue, COUNT_OF(newValue))) goto done; /* try to find out a name for the newly create key (max 100 times) */ for (valueNum = 1; valueNum < 100; valueNum++) { wsprintfW(valueName, newValue, valueNum); lRet = RegQueryValueExW(hKey, valueName, 0, 0, 0, 0); if (lRet == ERROR_FILE_NOT_FOUND) break; } if (lRet != ERROR_FILE_NOT_FOUND) { error_code_messagebox(hwnd, lRet); goto done; } lRet = RegSetValueExW(hKey, valueName, 0, valueType, (BYTE*)&valueDword, sizeof(DWORD)); if (lRet != ERROR_SUCCESS) { error_code_messagebox(hwnd, lRet); goto done; } result = TRUE; done: RegCloseKey(hKey); return result; }
/* display a driver specific configuration dialog */ static void configureAudioDriver(HWND hDlg) { const AUDIO_DRIVER *pAudioDrv = &loadedAudioDrv[toConfigure]; if (strlen(pAudioDrv->szDriver) != 0) { HDRVR hdrvr; char wine_driver[MAX_NAME_LENGTH + 9]; sprintf(wine_driver, "wine%s.drv", pAudioDrv->szDriver); hdrvr = OpenDriverA(wine_driver, 0, 0); if (hdrvr != 0) { if (SendDriverMessage(hdrvr, DRV_QUERYCONFIGURE, 0, 0) != 0) { DRVCONFIGINFO dci; LONG lRes; dci.dwDCISize = sizeof (dci); dci.lpszDCISectionName = NULL; dci.lpszDCIAliasName = NULL; lRes = SendDriverMessage(hdrvr, DRV_CONFIGURE, 0, (LONG_PTR)&dci); } CloseDriver(hdrvr, 0, 0); } else { WCHAR wine_driverW[MAX_NAME_LENGTH+9]; WCHAR messageStr[256]; WCHAR str[1024]; MultiByteToWideChar (CP_ACP, 0, wine_driver, -1, wine_driverW, sizeof (wine_driverW)/sizeof(wine_driverW[0])); LoadStringW (GetModuleHandle (NULL), IDS_OPEN_DRIVER_ERROR, messageStr, sizeof(messageStr)/sizeof(messageStr[0])); wsprintfW (str, messageStr, wine_driverW); MessageBoxW (hDlg, str, NULL, MB_OK | MB_ICONERROR); } } }
void CNeeded::DrawString( int x, int y, int r, int g,int b, int a, bool bCenter, const char *pszText, ... ) { if( pszText == NULL ) return; va_list va_alist; char szBuffer[1024] = { '\0' }; wchar_t szString[1024] = { '\0' }; va_start( va_alist, pszText ); vsprintf( szBuffer, pszText, va_alist ); va_end( va_alist ); DWORD color = COLORCODE(r,g,b,a); wsprintfW( szString, L"%S", szBuffer ); int iWidth, iHeight; g_pMatySystemSurface->GetTextSize( font, szString , iWidth, iHeight ); g_pSurface->DrawSetTextFont(font); g_pMatySystemSurface->DrawSetTextPos( x - ( bCenter ? iWidth / 2 : 0 ), y ); g_pSurface->DrawSetTextColor( Color(RED(color),GREEN(color),BLUE(color),ALPHA(color)) ); g_pSurface->DrawPrintText( szString, wcslen( szString ) ); }
static HRESULT WINAPI MMDevice_GetId(IMMDevice *iface, WCHAR **itemid) { MMDevice *This = impl_from_IMMDevice(iface); WCHAR *str; GUID *id = &This->devguid; static const WCHAR formatW[] = { '{','0','.','0','.','0','.','0','0','0','0','0','0','0','0','}','.', '{','%','0','8','X','-','%','0','4','X','-', '%','0','4','X','-','%','0','2','X','%','0','2','X','-', '%','0','2','X','%','0','2','X','%','0','2','X','%','0','2','X', '%','0','2','X','%','0','2','X','}',0 }; TRACE("(%p)->(%p)\n", This, itemid); if (!itemid) return E_POINTER; *itemid = str = CoTaskMemAlloc(56 * sizeof(WCHAR)); if (!str) return E_OUTOFMEMORY; wsprintfW( str, formatW, id->Data1, id->Data2, id->Data3, id->Data4[0], id->Data4[1], id->Data4[2], id->Data4[3], id->Data4[4], id->Data4[5], id->Data4[6], id->Data4[7] ); return S_OK; }
/********************************************************************** * COMCAT_ICatRegister_RegisterCategories */ static HRESULT WINAPI COMCAT_ICatRegister_RegisterCategories( LPCATREGISTER iface, ULONG cCategories, CATEGORYINFO *rgci) { HKEY comcat_key; HRESULT res; TRACE("\n"); if (cCategories && rgci == NULL) return E_POINTER; /* Create (or open) the component categories key. */ res = create_classes_key(HKEY_CLASSES_ROOT, comcat_keyname, KEY_READ|KEY_WRITE, &comcat_key); if (res != ERROR_SUCCESS) return E_FAIL; for (; cCategories; --cCategories, ++rgci) { static const WCHAR fmt[] = { '%', 'l', 'X', 0 }; WCHAR keyname[CHARS_IN_GUID]; WCHAR valname[9]; HKEY cat_key; /* Create (or open) the key for this category. */ if (!StringFromGUID2(&rgci->catid, keyname, CHARS_IN_GUID)) continue; res = create_classes_key(comcat_key, keyname, KEY_READ|KEY_WRITE, &cat_key); if (res != ERROR_SUCCESS) continue; /* Set the value for this locale's description. */ wsprintfW(valname, fmt, rgci->lcid); RegSetValueExW(cat_key, valname, 0, REG_SZ, (const BYTE*)rgci->szDescription, (lstrlenW(rgci->szDescription) + 1) * sizeof(WCHAR)); RegCloseKey(cat_key); } RegCloseKey(comcat_key); return S_OK; }
void KillDpcTimer(HWND m_hWnd,ULONG ID,CMyList *m_list) { DWORD dwReadByte; CString DpcTimerNum; WCHAR lpwzAdd[50]; POSITION pos = m_list->GetFirstSelectedItemPosition(); //判断列表框中是否有选择项 int Item = m_list->GetNextSelectedItem(pos); //将列表中被选择的下一项索引值保存到数组中 //取序号 DpcTimerNum.Format(L"%s",m_list->GetItemText(Item,0)); // memset(lpwzNum,0,sizeof(lpwzNum)); // wcscat(lpwzNum,DpcTimerNum); // // MessageBoxW(0,lpwzNum,L"目标",0); // WideCharToMultiByte (CP_OEMCP,NULL,lpwzNum,-1,lpszNum,wcslen(lpwzNum),NULL,FALSE); for (int i = 0;i< (int)DpcTimer->ulCount;i++) { memset(lpwzAdd,0,sizeof(lpwzAdd)); wsprintfW(lpwzAdd,L"0x%08X",DpcTimer->MyTimer[i].TimerAddress); //MessageBoxW(0,lpwzAdd,DpcTimerNum,0); if (_wcsicmp(lpwzAdd,DpcTimerNum) == 0) { // MessageBoxW(0,DpcTimerNum,L"确认",0); HANDLE hThread = CreateThread(NULL,NULL,(LPTHREAD_START_ROUTINE)KillDpcTimerThread,(PVOID)i,0,NULL); WaitForSingleObject(hThread,-1); break; } } //删除当前选择的一行 m_list->DeleteAllItems(); QueryDpcTimer(m_hWnd,ID,m_list); }
BOOL CreateKey(HWND hwnd, HKEY hKeyRoot, LPCWSTR keyPath, LPWSTR keyName) { BOOL result = FALSE; LONG lRet = ERROR_SUCCESS; HKEY retKey = NULL; WCHAR newKey[MAX_NEW_KEY_LEN - 4]; int keyNum; HKEY hKey; lRet = RegOpenKeyExW(hKeyRoot, keyPath, 0, KEY_CREATE_SUB_KEY, &hKey); if (lRet != ERROR_SUCCESS) { error_code_messagebox(hwnd, lRet); goto done; } if (!LoadStringW(GetModuleHandleW(0), IDS_NEWKEY, newKey, COUNT_OF(newKey))) goto done; /* try to find out a name for the newly create key (max 100 times) */ for (keyNum = 1; keyNum < 100; keyNum++) { wsprintfW(keyName, newKey, keyNum); lRet = RegOpenKeyW(hKey, keyName, &retKey); if (lRet != ERROR_SUCCESS) break; RegCloseKey(retKey); } if (lRet == ERROR_SUCCESS) goto done; lRet = RegCreateKeyW(hKey, keyName, &retKey); if (lRet != ERROR_SUCCESS) { error_code_messagebox(hwnd, lRet); goto done; } result = TRUE; done: RegCloseKey(retKey); return result; }
LRESULT MainWindow::OnNewClient(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled) { uint32_t pid = (uint32_t)wParam; uint32_t tid = (uint32_t)lParam; /* Find the place to insert item */ WCHAR text[256]; wsprintfW(text, L"PID: %d, TID: %d\n", pid, tid); int parentId = -1; HTREEITEM item = NULL; for (int i = (int)m_clients.size() - 1; i >= 0; i--) { Client *parent = m_clients[i].front().get(); if (parent->pid == pid) { Client *after = m_clients[i].back().get(); item = m_processTree.InsertItem(TVIF_TEXT, text, 0, 0, TVIS_BOLD, TVIS_BOLD, 0, parent->item, after->item); parentId = i; break; } } if (!item) { item = m_processTree.InsertItem(TVIF_TEXT, text, 0, 0, TVIS_BOLD, TVIS_BOLD, 0, NULL, NULL); m_clients.emplace_back(); parentId = (int)m_clients.size() - 1; } std::unique_ptr<Client> client = std::make_unique<Client>(); client->pid = pid; client->tid = tid; client->item = item; m_processTree.SetItemData(client->item, (DWORD_PTR)client.get()); InitLogViewer(client->logViewer); if (m_splitter.GetSplitterPane(SPLIT_PANE_RIGHT) == m_defaultLogViewer) SetCurrentLogViewer(client->logViewer); m_clients[parentId].push_back(std::move(client)); m_processTree.Invalidate(); return 0; }
int wmain(int argc, WCHAR* argv[]) { if (argc != 2) return 0; WinFile File, OutFile; ULONG InSize; PBYTE InBuffer = nullptr; WCHAR lpFileName[MAX_PATH] = { 0 }; do { if (FAILED(File.Open(argv[1], WinFile::FileRead))) break; InSize = File.GetSize32(); InBuffer = (PBYTE)GlobalAlloc(0, InSize); if (!InBuffer) break; File.Read(InBuffer, InSize); wsprintfW(lpFileName, L"%s.bmp", argv[1]); GetBMPData(InBuffer); if (FAILED(OutFile.Open(lpFileName, WinFile::FileWrite))) break; OutFile.Write(InBuffer, InSize); OutFile.Release(); } while (0); if (InBuffer) GlobalFree(InBuffer); File.Release(); return 0; }
void CMyDlg::OnPaint() { CPaintDC dc(this); CRect rcClient; GetClientRect(&rcClient); Graphics graphics(dc); if (version&&bIsAero) graphics.Clear(Color.Black); else graphics.Clear(Color.White); Bitmap CacheImage(rcClient.Width(),rcClient.Height()); Graphics buffer(&CacheImage); buffer.SetSmoothingMode(SmoothingModeAntiAlias); buffer.SetInterpolationMode(InterpolationModeHighQualityBicubic); Image *logo; Image *button; ImageFromIDResource(2,"png",logo); ImageFromIDResource(1,"png",button); buffer.DrawImage(logo, -5,20); buffer.DrawImage(button, 165,122); buffer.DrawImage(button, 350,122); FontFamily fontFamily(version?L"微软雅黑":L"宋体"); StringFormat strformat; wchar_t pszbuf[512]; wsprintfW(pszbuf,L"本程序适用于 迅雷5.9 系列\n如果本软件有错,我概不负责,但我会尽力解决。\n只有极少数时候需要您指定安装目录(比如非官方版)。\n如果会员补丁失效,重新破解即可。\n\n\n请选择: 一键增强 %s取消增强\n\n2010年4月7日更新 www.shuax.com",version?L" ":L" "); GraphicsPath path; path.AddString(pszbuf, wcslen(pszbuf), &fontFamily, FontStyleRegular, version?15:16, Gdiplus::Point(version?90:80,version?9:20), &strformat ); Pen pen(Color(18, 255, 255, 255), 3.0); //pen.SetLineJoin(LineJoinRound); buffer.DrawPath(&pen, &path); SolidBrush brush(Color(0,0,0)); buffer.FillPath(&brush, &path); graphics.DrawImage(&CacheImage, 0, 0); graphics.ReleaseHDC(dc); }
BOOL WINAPI InjectLibA(DWORD dwProcessId, PCSTR pszLibFile) { // Allocate a (stack) buffer for the Unicode version of the pathname PWSTR pszLibFileW = (PWSTR) _alloca((lstrlenA(pszLibFile) + 1) * sizeof(WCHAR)); // Convert the ANSI pathname to its Unicode equivalent wsprintfW(pszLibFileW, L"%S", pszLibFile); // Call the Unicode version of the function to actually do the work. return(InjectLibW(dwProcessId, pszLibFileW)); }
static BOOL variant_to_nscolor(const VARIANT *v, nsAString *nsstr) { switch(V_VT(v)) { case VT_BSTR: nsAString_Init(nsstr, V_BSTR(v)); return TRUE; case VT_I4: { PRUnichar buf[10]; static const WCHAR formatW[] = {'#','%','x',0}; wsprintfW(buf, formatW, V_I4(v)); nsAString_Init(nsstr, buf); return TRUE; } default: FIXME("invalid color %s\n", debugstr_variant(v)); } return FALSE; }
static void test_navigate_page(void) { TASKDIALOGCONFIG info = {0}; static const WCHAR textW[] = {'t', 'e', 'x', 't', 0}; static const WCHAR button_format[] = {'%', '0', '2', 'd', 0}; TASKDIALOG_BUTTON radio_buttons[TEST_NUM_RADIO_BUTTONS]; WCHAR radio_button_titles[TEST_NUM_BUTTONS * 3]; int i; /* Init radio buttons */ for (i = 0; i < TEST_NUM_RADIO_BUTTONS; i++) { WCHAR *text = &radio_button_titles[i * 3]; wsprintfW(text, button_format, i); radio_buttons[i].pszButtonText = text; radio_buttons[i].nButtonID = ID_START_RADIO_BUTTON + i; } info.cbSize = sizeof(TASKDIALOGCONFIG); info.pfCallback = taskdialog_callback_proc; info.lpCallbackData = test_ref_data; info.dwCommonButtons = TDCBF_OK_BUTTON; info.cRadioButtons = TEST_NUM_RADIO_BUTTONS; info.pRadioButtons = radio_buttons; navigated_info = info; navigated_info.pszVerificationText = textW; navigated_info.dwFlags = TDF_VERIFICATION_FLAG_CHECKED; run_test(&info, IDOK, ID_START_RADIO_BUTTON, TRUE, msg_return_navigated_page, "navigate page: default"); /* TDM_NAVIGATE_PAGE doesn't check cbSize. * And null taskconfig pointer crash applicatioin, thus doesn't check pointer either */ navigated_info.cbSize = 0; run_test(&info, IDOK, ID_START_RADIO_BUTTON, TRUE, msg_return_navigated_page, "navigate page: invalid taskconfig cbSize"); }
static void native_cond_wait(rb_thread_cond_t *cond, rb_thread_lock_t *mutex) { DWORD r; struct cond_event_entry entry; //RHO //WinMo BUG: in release mode CreateEventW without name inside non-main thread does not work static int nCounter = 0; wchar_t buf[20]; wsprintfW(buf, L"REvent%d", nCounter); nCounter = nCounter + 1; entry.next = 0; entry.event = CreateEventW(0, FALSE, FALSE, buf); //RHO /* cond is guarded by mutex */ if (cond->next) { cond->last->next = &entry; cond->last = &entry; } else { cond->next = &entry; cond->last = &entry; } native_mutex_unlock(mutex); { r = WaitForSingleObject(entry.event, INFINITE); if (r != WAIT_OBJECT_0) { rb_bug("native_cond_wait: WaitForSingleObject returns %lu", r); } } native_mutex_lock(mutex); w32_close_handle(entry.event); }
void MainWnd_OnOpenRegKey(HWND hwnd) { static const WCHAR s_szRegeditKey[] = L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Applets\\Regedit"; WCHAR sz[MAX_STRING]; // open regedit key HKEY hKey = NULL; LSTATUS Result = RegCreateKeyExW(HKEY_CURRENT_USER, s_szRegeditKey, 0, NULL, 0, KEY_WRITE, NULL, &hKey, NULL); if (Result != ERROR_SUCCESS) { LoadStringW(g_hInstance, IDS_CANTOPENKEY, sz, _countof(sz)); MessageBoxW(hwnd, sz, NULL, MB_ICONERROR); return; } // set LastKey value wsprintfW(sz, L"HKEY_LOCAL_MACHINE\\%s", g_pszKey); DWORD dwSize = sizeof(sz); Result = RegSetValueExW(hKey, L"LastKey", 0, REG_SZ, (LPBYTE)sz, dwSize); // close now RegCloseKey(hKey); if (Result != ERROR_SUCCESS) { LoadStringW(g_hInstance, IDS_CANTOPENKEY, sz, _countof(sz)); MessageBoxW(hwnd, sz, NULL, MB_ICONERROR); return; } // open by regedit ShellExecuteW(hwnd, NULL, L"regedit.exe", NULL, NULL, SW_SHOWNORMAL); }