P
Paul E
I have some data that I want to save inside my .exe instead of
delivering it as separate files. When I was using MFC, I would create a
custom resource in my .RC file, then use FindResource and LoadResource.
What is the equivolent in .NET, or is there another way to achieve my
goal?
I created a custom resource in my app.rc file, just like I would have
in MFC, but I have no idea how to do anything with it. What is the call
to get that resource in a variable I can see?
In other words, I'd like the equivolent of this routine:
CString PutResourceInString(HINSTANCE hInstance, const TCHAR*
szSection, UINT uiResource)
{
HRSRC hFound =
::FindResource(hInstance,MAKEINTRESOURCE(uiResource),TEXT(szSection));
HGLOBAL hRes = ::LoadResource(hInstance, hFound);
int iSize = ::SizeofResource(hInstance, hFound);
LPVOID lpBuff = ::LockResource(hRes);
CString csRet;
char* psz = csRet.GetBuffer(iSize+1);
memcpy(psz, lpBuff, iSize);
psz[iSize] = '\0';
csRet.ReleaseBuffer();
::UnlockResource(hRes);
::FreeResource(hRes);
csRet.Replace("\r\n", "\n");
return csRet;
}
Thanks!
delivering it as separate files. When I was using MFC, I would create a
custom resource in my .RC file, then use FindResource and LoadResource.
What is the equivolent in .NET, or is there another way to achieve my
goal?
I created a custom resource in my app.rc file, just like I would have
in MFC, but I have no idea how to do anything with it. What is the call
to get that resource in a variable I can see?
In other words, I'd like the equivolent of this routine:
CString PutResourceInString(HINSTANCE hInstance, const TCHAR*
szSection, UINT uiResource)
{
HRSRC hFound =
::FindResource(hInstance,MAKEINTRESOURCE(uiResource),TEXT(szSection));
HGLOBAL hRes = ::LoadResource(hInstance, hFound);
int iSize = ::SizeofResource(hInstance, hFound);
LPVOID lpBuff = ::LockResource(hRes);
CString csRet;
char* psz = csRet.GetBuffer(iSize+1);
memcpy(psz, lpBuff, iSize);
psz[iSize] = '\0';
csRet.ReleaseBuffer();
::UnlockResource(hRes);
::FreeResource(hRes);
csRet.Replace("\r\n", "\n");
return csRet;
}
Thanks!