Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>As Manuell says, you use <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/ms648042.aspx" rel="nofollow">FindResource()</a>, <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/ms648046.aspx" rel="nofollow">LoadResource()</a> and probably <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/ms648047%28v=vs.85%29.aspx" rel="nofollow">LockResource()</a> and <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/ms648048%28v=vs.85%29.aspx" rel="nofollow">SizeofResource()</a></p> <p>I happen to have some code which does pulls out a resource and writes it to a file, and may help with your understanding of the API in question.</p> <pre><code>void WriteResourceToFile( HANDLE hFile, const _tstring &amp;resourceName, const _tstring &amp;resourceType, HMODULE hModule) { HRSRC hResource = ::FindResource( hModule, resourceName.c_str(), resourceType.c_str()); if (!hResource) { const DWORD lastError = ::GetLastError(); throw CWin32Exception( _T("WriteResourceToFile() - FindResource"), lastError); } HGLOBAL hGlobal = ::LoadResource(hModule, hResource); if (!hGlobal) { const DWORD lastError = ::GetLastError(); throw CWin32Exception( _T("WriteResourceToFile() - LoadResource"), lastError); } void *pData = ::LockResource(hGlobal); if (!pData) { const DWORD lastError = ::GetLastError(); throw CWin32Exception( _T("WriteResourceToFile() - LockResource"), lastError); } const DWORD bytes = ::SizeofResource(hModule, hResource); DWORD bytesWritten = 0; if (!::WriteFile(hFile, pData, bytes, &amp;bytesWritten, 0)) { const DWORD lastError = ::GetLastError(); throw CWin32Exception( _T("WriteResourceToFile() - WriteFile"), lastError); } if (bytesWritten != bytes) { throw CWin32Exception( _T("WriteResourceToFile() - WriteFile"), _T("Wrote less bytes (") + ToString(bytesWritten) + _T("( than expected: ") + ToString(bytes)); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload