Click here to Skip to main content
15,900,461 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralMFC OnClose() behaviour Pin
J.B.25-May-04 17:03
J.B.25-May-04 17:03 
GeneralRe: MFC OnClose() behaviour Pin
Bob Stanneveld25-May-04 21:09
Bob Stanneveld25-May-04 21:09 
GeneralRe: MFC OnClose() behaviour Pin
Diddy26-May-04 0:13
Diddy26-May-04 0:13 
GeneralRe: MFC OnClose() behaviour Pin
David Crow26-May-04 3:30
David Crow26-May-04 3:30 
GeneralRe: MFC OnClose() behaviour Pin
J.B.27-May-04 0:46
J.B.27-May-04 0:46 
GeneralVC.Net In VC6 Pin
Anonymous25-May-04 13:56
Anonymous25-May-04 13:56 
GeneralRe: VC.Net In VC6 Pin
Anonymous25-May-04 15:54
Anonymous25-May-04 15:54 
GeneralRe: VC.Net In VC6 Pin
Ryan Binns25-May-04 18:14
Ryan Binns25-May-04 18:14 
GeneralRe: VC.Net In VC6 Pin
Anonymous25-May-04 18:40
Anonymous25-May-04 18:40 
GeneralRe: VC.Net In VC6 Pin
Ryan Binns25-May-04 18:43
Ryan Binns25-May-04 18:43 
GeneralRe: VC.Net In VC6 Pin
Jim A. Johnson25-May-04 19:18
Jim A. Johnson25-May-04 19:18 
GeneralRe: VC.Net In VC6 Pin
Ryan Binns25-May-04 23:36
Ryan Binns25-May-04 23:36 
GeneralRe: VC.Net In VC6 Pin
Jim A. Johnson26-May-04 4:39
Jim A. Johnson26-May-04 4:39 
GeneralGetting Text from Seperate Dialog Pin
Eversman25-May-04 13:48
Eversman25-May-04 13:48 
GeneralRe: Getting Text from Seperate Dialog Pin
Gary R. Wheeler25-May-04 14:45
Gary R. Wheeler25-May-04 14:45 
GeneralRe: Getting Text from Seperate Dialog Pin
avenger_sb2525-May-04 18:10
avenger_sb2525-May-04 18:10 
GeneralVC++.NET compiler running in VC++6 Errors Pin
---Mark---25-May-04 13:31
---Mark---25-May-04 13:31 
GeneralRe: VC++.NET compiler running in VC++6 Errors Pin
Anonymous25-May-04 13:39
Anonymous25-May-04 13:39 
GeneralRe: VC++.NET compiler running in VC++6 Errors Pin
---Mark---25-May-04 13:43
---Mark---25-May-04 13:43 
GeneralRe: VC++.NET compiler running in VC++6 Errors Pin
Anonymous25-May-04 13:47
Anonymous25-May-04 13:47 
GeneralRe: VC++.NET compiler running in VC++6 Errors Pin
---Mark---25-May-04 13:53
---Mark---25-May-04 13:53 
GeneralExtracting files from resource Pin
Anonymous25-May-04 13:28
Anonymous25-May-04 13:28 
GeneralRe: Extracting files from resource Pin
gUrM33T25-May-04 18:04
gUrM33T25-May-04 18:04 
GeneralRe: Extracting files from resource Pin
Diddy26-May-04 0:20
Diddy26-May-04 0:20 
GeneralRe: Extracting files from resource Pin
Roger Allen26-May-04 2:41
Roger Allen26-May-04 2:41 
Here is how I have done it in an MFC application:

In the .rc2 file, include the file you want to extract

ResourceName ResourceType "ResourceFilename"


To extract it:

	ExtractFile("ResourceName", "ResourceType", pathname);

// note that hInstance is the instance off the DLL/exe which has the resource

bool ExtractFile(const CString& resourceID, const CString& resourceType, const CString& filename)
{
	// need to extract the resource out into the filename supplied
	bool bOK = true;
	HANDLE hRes = ::LoadResource(hInstance, ::FindResource(hInstance, resourceID, resourceType));
	if (hRes != INVALID_HANDLE_VALUE)
	{
		// we loaded it, not get the text from it
		DWORD sizeOfResource = ::SizeofResource(hInstance, ::FindResource(hInstance, resourceID, resourceType));
		char *lpRes = (char*)::LockResource(hRes);
		CFile file;

		if (file.Open(filename, CFile::modeCreate | CFile::modeWrite))
		{
			// write the resource out to the file
			file.WriteHuge(lpRes, sizeOfResource);
			file.Close();
		}
		else
		{
			bOK = false;
		}
		// release the resource
		::UnlockResource(hRes);
		::FreeResource(hRes);
	}
	return bOK;
}



Roger Allen - Sonork 100.10016
Strong Sad: I am sad I am flying
Who is your favorite Strong?

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.