本文整理汇总了C++中FindResourceW函数的典型用法代码示例。如果您正苦于以下问题:C++ FindResourceW函数的具体用法?C++ FindResourceW怎么用?C++ FindResourceW使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了FindResourceW函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test_find_resource
static void test_find_resource(void)
{
HRSRC rsrc;
rsrc = FindResourceW( GetModuleHandleW(NULL), MAKEINTRESOURCEW(1), (LPCWSTR)RT_MENU );
ok( rsrc != 0, "resource not found\n" );
rsrc = FindResourceExW( GetModuleHandleW(NULL), (LPCWSTR)RT_MENU, MAKEINTRESOURCEW(1),
MAKELANGID( LANG_NEUTRAL, SUBLANG_NEUTRAL ));
ok( rsrc != 0, "resource not found\n" );
rsrc = FindResourceExW( GetModuleHandleW(NULL), (LPCWSTR)RT_MENU, MAKEINTRESOURCEW(1),
MAKELANGID( LANG_GERMAN, SUBLANG_DEFAULT ));
ok( rsrc != 0, "resource not found\n" );
SetLastError( 0xdeadbeef );
rsrc = FindResourceW( GetModuleHandleW(NULL), MAKEINTRESOURCEW(1), (LPCWSTR)RT_DIALOG );
ok( !rsrc, "resource found\n" );
ok( GetLastError() == ERROR_RESOURCE_TYPE_NOT_FOUND, "wrong error %u\n", GetLastError() );
SetLastError( 0xdeadbeef );
rsrc = FindResourceW( GetModuleHandleW(NULL), MAKEINTRESOURCEW(2), (LPCWSTR)RT_MENU );
ok( !rsrc, "resource found\n" );
ok( GetLastError() == ERROR_RESOURCE_NAME_NOT_FOUND, "wrong error %u\n", GetLastError() );
SetLastError( 0xdeadbeef );
rsrc = FindResourceExW( GetModuleHandleW(NULL), (LPCWSTR)RT_MENU, MAKEINTRESOURCEW(1),
MAKELANGID( LANG_ENGLISH, SUBLANG_DEFAULT ) );
ok( !rsrc, "resource found\n" );
ok( GetLastError() == ERROR_RESOURCE_LANG_NOT_FOUND, "wrong error %u\n", GetLastError() );
SetLastError( 0xdeadbeef );
rsrc = FindResourceExW( GetModuleHandleW(NULL), (LPCWSTR)RT_MENU, MAKEINTRESOURCEW(1),
MAKELANGID( LANG_FRENCH, SUBLANG_DEFAULT ) );
ok( !rsrc, "resource found\n" );
ok( GetLastError() == ERROR_RESOURCE_LANG_NOT_FOUND, "wrong error %u\n", GetLastError() );
}
示例2: OleUIPasteSpecialW
/***********************************************************************
* OleUIPasteSpecialW (OLEDLG.22)
*/
UINT WINAPI OleUIPasteSpecialW(LPOLEUIPASTESPECIALW ps)
{
LPCDLGTEMPLATEW dlg_templ = (LPCDLGTEMPLATEW)ps->hResource;
UINT ret;
TRACE("(%p)\n", ps);
if(TRACE_ON(ole)) dump_pastespecial(ps);
if(!ps->lpSrcDataObj)
OleGetClipboard(&ps->lpSrcDataObj);
if(ps->hInstance || !ps->hResource)
{
HINSTANCE hInst = ps->hInstance ? ps->hInstance : OLEDLG_hInstance;
const WCHAR *name = ps->hInstance ? ps->lpszTemplate : MAKEINTRESOURCEW(IDD_PASTESPECIAL4);
HRSRC hrsrc;
if(name == NULL) return OLEUI_ERR_LPSZTEMPLATEINVALID;
hrsrc = FindResourceW(hInst, name, MAKEINTRESOURCEW(RT_DIALOG));
if(!hrsrc) return OLEUI_ERR_FINDTEMPLATEFAILURE;
dlg_templ = LoadResource(hInst, hrsrc);
if(!dlg_templ) return OLEUI_ERR_LOADTEMPLATEFAILURE;
}
ret = DialogBoxIndirectParamW(OLEDLG_hInstance, dlg_templ, ps->hWndOwner, ps_dlg_proc, (LPARAM)ps);
return ret;
}
示例3: AtlAxCreateDialogW
/***********************************************************************
* AtlAxCreateDialogW [[email protected]]
*
* See AtlAxCreateDialogA
*
*/
HWND WINAPI AtlAxCreateDialogW(HINSTANCE hInst, LPCWSTR name, HWND owner, DLGPROC dlgProc ,LPARAM param)
{
HRSRC hrsrc;
HGLOBAL hgl;
LPCDLGTEMPLATEW ptr;
LPDLGTEMPLATEW newptr;
HWND res;
TRACE("(%p %s %p %p %lx)\n", hInst, debugstr_w(name), owner, dlgProc, param);
hrsrc = FindResourceW( hInst, name, (LPWSTR)RT_DIALOG );
if ( !hrsrc )
return NULL;
hgl = LoadResource (hInst, hrsrc);
if ( !hgl )
return NULL;
ptr = LockResource ( hgl );
if (!ptr)
{
FreeResource( hgl );
return NULL;
}
newptr = AX_ConvertDialogTemplate( ptr );
if ( newptr )
{
res = CreateDialogIndirectParamW( hInst, newptr, owner, dlgProc, param );
HeapFree( GetProcessHeap(), 0, newptr );
} else
res = NULL;
FreeResource ( hrsrc );
return res;
}
示例4: EngFindResource
/*
* @implemented
*/
PVOID WINAPI
EngFindResource(HANDLE h,
int iName,
int iType,
PULONG pulSize)
{
HRSRC HRSrc;
DWORD Size = 0;
HGLOBAL Hg;
LPVOID Lock = NULL;
if ((HRSrc = FindResourceW( (HMODULE) h, MAKEINTRESOURCEW(iName), MAKEINTRESOURCEW(iType))))
{
if ((Size = SizeofResource( (HMODULE) h, HRSrc )))
{
if ((Hg = LoadResource( (HMODULE) h, HRSrc )))
{
Lock = LockResource( Hg );
}
}
}
*pulSize = Size;
return (PVOID) Lock;
}
示例5: get_first_resource
/***********************************************************************
* get_first_resource
*
* Helper for create_app_icon_images(). Enum proc for EnumResourceNamesW()
* which just gets the handle for the first resource and stops further
* enumeration.
*/
static BOOL CALLBACK get_first_resource(HMODULE module, LPCWSTR type, LPWSTR name, LONG_PTR lparam)
{
HRSRC *res_info = (HRSRC*)lparam;
*res_info = FindResourceW(module, name, (LPCWSTR)RT_GROUP_ICON);
return FALSE;
}
示例6: GetDialogType
/////////////////////////////////////////////////////////////////////////////
// LaunchUrlmonDialog
/////////////////////////////////////////////////////////////////////////////
int LaunchUrlmonDialog
(
IN HWND hWnd,
IN DWORD dwAction,
IN DWORD dwPermissions,
IN LPCTSTR lpszText
)
{
int iRet = ERROR_CALL_NOT_IMPLEMENTED;
UMDLGPARAMS umparams;
umparams.eDlgType = GetDialogType(dwAction, dwPermissions);
umparams.pszMsg = lpszText;
iRet = DialogBoxIndirectParamW(HINST_RESDLL,
(LPCDLGTEMPLATEW)LoadResource(HINST_RESDLL,
FindResourceW(HINST_RESDLL,
MAKEINTRESOURCEW(IDD_URLMON),
RT_DIALOG)),
SHGetLastActiveWindow(hWnd),
(DLGPROC)UrlmonDialogProc,
(LPARAM)&umparams);
return iRet;
}
示例7: ShellAboutW
/*************************************************************************
* ShellAboutW [SHELL32.289]
*/
BOOL WINAPI ShellAboutW( HWND hWnd, LPCWSTR szApp, LPCWSTR szOtherStuff,
HICON hIcon )
{
ABOUT_INFO info;
HRSRC hRes;
DLGTEMPLATE *DlgTemplate;
BOOL bRet;
TRACE("\n");
// DialogBoxIndirectParamW will be called with the hInstance of the calling application, so we have to preload the dialog template
hRes = FindResourceW(shell32_hInstance, MAKEINTRESOURCEW(IDD_ABOUT), (LPWSTR)RT_DIALOG);
if(!hRes)
return FALSE;
DlgTemplate = (DLGTEMPLATE *)LoadResource(shell32_hInstance, hRes);
if(!DlgTemplate)
return FALSE;
info.szApp = szApp;
info.szOtherStuff = szOtherStuff;
info.hIcon = hIcon ? hIcon : LoadIconW( 0, (LPWSTR)IDI_WINLOGO );
bRet = DialogBoxIndirectParamW((HINSTANCE)GetWindowLongPtrW( hWnd, GWLP_HINSTANCE ),
DlgTemplate, hWnd, AboutDlgProc, (LPARAM)&info );
return bRet;
}
示例8: ANIMATE_LoadResW
static BOOL ANIMATE_LoadResW(ANIMATE_INFO *infoPtr, HINSTANCE hInst, LPCWSTR lpName)
{
static const WCHAR aviW[] = { 'A', 'V', 'I', 0 };
HRSRC hrsrc;
MMIOINFO mminfo;
LPVOID lpAvi;
hrsrc = FindResourceW(hInst, lpName, aviW);
if (!hrsrc)
return FALSE;
infoPtr->hRes = LoadResource(hInst, hrsrc);
if (!infoPtr->hRes)
return FALSE;
lpAvi = LockResource(infoPtr->hRes);
if (!lpAvi)
return FALSE;
memset(&mminfo, 0, sizeof(mminfo));
mminfo.fccIOProc = FOURCC_MEM;
mminfo.pchBuffer = lpAvi;
mminfo.cchBuffer = SizeofResource(hInst, hrsrc);
infoPtr->hMMio = mmioOpenW(NULL, &mminfo, MMIO_READ);
if (!infoPtr->hMMio)
{
FreeResource(infoPtr->hRes);
return FALSE;
}
return TRUE;
}
示例9: GetManifestStringFromModule
BOOL
GetManifestStringFromModule(HMODULE mod, LPSTR manifest, SIZE_T size)
{
HRSRC rsrc = FindResourceW(mod, MAKEINTRESOURCE(1), RT_MANIFEST);
if(!rsrc)
return FALSE;
ULONG rsrc_size = SizeofResource(mod, rsrc);
HGLOBAL grsrc = LoadResource(mod, rsrc);
if(!grsrc)
return FALSE;
PVOID prsrc = LockResource(grsrc);
if(!prsrc)
{
FreeResource(grsrc);
return FALSE;
}
ByteBuffer tmp;
tmp.resize(rsrc_size);
memcpy(&tmp[0], prsrc, rsrc_size);
tmp.push_back(0);
StringCbCopyA(manifest, size, (LPCSTR) &tmp[0]);
UnlockResource(prsrc);
FreeResource(grsrc);
return TRUE;
}
示例10: SH_CreatePropertySheetPage
HPROPSHEETPAGE
SH_CreatePropertySheetPage(WORD wDialogId, DLGPROC pfnDlgProc, LPARAM lParam, LPCWSTR pwszTitle)
{
HRSRC hRes = FindResourceW(shell32_hInstance, MAKEINTRESOURCEW(wDialogId), (LPWSTR)RT_DIALOG);
if (hRes == NULL)
{
ERR("failed to find resource id\n");
return NULL;
}
LPVOID pTemplate = LoadResource(shell32_hInstance, hRes);
if (pTemplate == NULL)
{
ERR("failed to load resource\n");
return NULL;
}
PROPSHEETPAGEW Page;
memset(&Page, 0x0, sizeof(PROPSHEETPAGEW));
Page.dwSize = sizeof(PROPSHEETPAGEW);
Page.dwFlags = PSP_DLGINDIRECT;
Page.pResource = (DLGTEMPLATE*)pTemplate;
Page.pfnDlgProc = pfnDlgProc;
Page.lParam = lParam;
Page.pszTitle = pwszTitle;
if (pwszTitle)
Page.dwFlags |= PSP_USETITLE;
return CreatePropertySheetPageW(&Page);
}
示例11: add_authors
static void add_authors( HWND list )
{
static const WCHAR eol[] = {'\r','\n',0};
static const WCHAR authors[] = {'A','U','T','H','O','R','S',0};
WCHAR *strW, *start, *end;
HRSRC rsrc = FindResourceW( shell32_hInstance, authors, (LPCWSTR)RT_RCDATA );
char *strA = LockResource( LoadResource( shell32_hInstance, rsrc ));
DWORD sizeW, sizeA = SizeofResource( shell32_hInstance, rsrc );
if (!strA) return;
sizeW = MultiByteToWideChar( CP_UTF8, 0, strA, sizeA, NULL, 0 ) + 1;
if (!(strW = HeapAlloc( GetProcessHeap(), 0, sizeW * sizeof(WCHAR) ))) return;
MultiByteToWideChar( CP_UTF8, 0, strA, sizeA, strW, sizeW );
strW[sizeW - 1] = 0;
start = strpbrkW( strW, eol ); /* skip the header line */
while (start)
{
while (*start && strchrW( eol, *start )) start++;
if (!*start) break;
end = strpbrkW( start, eol );
if (end) *end++ = 0;
SendMessageW( list, LB_ADDSTRING, -1, (LPARAM)start );
start = end;
}
HeapFree( GetProcessHeap(), 0, strW );
}
示例12: GetMemory
// Fills the structure in mk_Memory with a pointer to the resource in memory
// mk_Resource.sw_Module may be = "" if the cabinet is in the EXE which created the process.
BOOL GetMemory()
{
CStrW sw_ResName = mk_Resource.sw_Name;
if (mk_Resource.u32_ID) sw_ResName.FormatResource(mk_Resource.u32_ID);
WCHAR* u16_Module = 0; // Resource is in the calling process
if (mk_Resource.sw_Module.Len())
u16_Module = mk_Resource.sw_Module;
// Load the resource (via Filemapping, there is no memory consumption here)
HMODULE h_DLL = GetModuleHandleW(u16_Module);
HRSRC h_Resource = FindResourceW(h_DLL, sw_ResName, mk_Resource.sw_Type);
HGLOBAL h_Global = LoadResource (h_DLL, h_Resource);
mk_Memory.p_Addr = LockResource (h_Global);
mk_Memory.s32_Size = SizeofResource(h_DLL, h_Resource);
mk_Memory.s32_Pos = 0;
if (mk_Memory.p_Addr == 0 || mk_Memory.s32_Size == 0)
{
mi_Error.Set(FDIERROR_INVAL_RESOURCE,0,0);
return FALSE;
}
return TRUE;
}
示例13: FindResourceW
bool KAppRes::PrepareRes()
{
bool retval = false;
KFilePath pathRes = KFilePath::GetFilePath(g_hInstance);
HRSRC hResInfo = NULL;
HGLOBAL hResDat = NULL;
PVOID pResBuffer = NULL;
DWORD dwResBuffer;
wchar_t szTempPath[MAX_PATH] = { 0 };
wchar_t szTempFilePath[MAX_PATH] = { 0 };
//BOOL fRetCode;
//DWORD dwWritten;
pathRes.RemoveExtension();
pathRes.AddExtension(L"kui");
if (GetFileAttributesW(pathRes) != INVALID_FILE_ATTRIBUTES)
{
m_strResPackPath = pathRes.value();
}
else
{
hResInfo = FindResourceW(_ModulePtr->GetResourceInstance(), L"kuires.dat", L"SKIN");
if (!hResInfo)
goto clean0;
hResDat = LoadResource(_ModulePtr->GetResourceInstance(), hResInfo);
if (!hResDat)
goto clean0;
pResBuffer = LockResource(hResDat);
if (!pResBuffer)
goto clean0;
dwResBuffer = SizeofResource(_ModulePtr->GetResourceInstance(), hResInfo);
m_memZipRes.SetData(pResBuffer, dwResBuffer);
/* GetTempPathW(MAX_PATH, szTempPath);
GetTempFileNameW(szTempPath, L"kui", 0, szTempFilePath);
m_hTempRes = CreateFileW(szTempFilePath, GENERIC_ALL, FILE_SHARE_READ, NULL,
CREATE_ALWAYS, FILE_ATTRIBUTE_TEMPORARY, NULL);
if (INVALID_HANDLE_VALUE == m_hTempRes)
goto clean0;
fRetCode = WriteFile(m_hTempRes, pResBuffer, dwResBuffer, &dwWritten, NULL);
if (!fRetCode)
goto clean0;
fRetCode = FlushFileBuffers(m_hTempRes);
m_strResPackPath = szTempFilePath;*/
}
retval = true;
clean0:
return retval;
}
示例14: WriteAppletToFile
BOOL WINAPI WriteAppletToFile(HANDLE FileHandle)
{
BOOL Success = FALSE;
HRSRC ResourceHandle = NULL;
HGLOBAL Resource = NULL;
DWORD BytesCount = 0;
LPVOID Bytes = NULL;
ResourceHandle = FindResourceW(
g_ModuleHandle,
MAKEINTRESOURCEW(IDR_X64_EXE),
RT_RCDATA
);
if (!ResourceHandle)
return FALSE;
BytesCount = SizeofResource(
g_ModuleHandle,
ResourceHandle
);
Resource = LoadResource(
g_ModuleHandle,
ResourceHandle
);
if (!Resource)
goto Cleanup;
Bytes = LockResource(Resource);
if (!Bytes)
goto Cleanup;
Success = WriteFile(
FileHandle,
Bytes,
BytesCount,
NULL,
NULL
);
Cleanup:
if (Bytes)
UnlockResource(Bytes);
if (Resource)
FreeResource(Resource);
return Success;
}
示例15: loadResourceWin32
Resource loadResourceWin32(int name) {
HMODULE handle = GetModuleHandle(L"jsrdbg");
HRSRC rc = FindResourceW(handle, MAKEINTRESOURCE(name), RT_RCDATA);
if (rc == nullptr) {
auto errnum = GetLastError();
throw std::runtime_error("Failed loading resource: " + systemErrorString(errnum));
}
HGLOBAL rcData = LoadResource(handle, rc);
auto len = SizeofResource(handle, rc);
auto addr = static_cast<void*>(LockResource(rcData));
return Resource(addr, len);
}