VilePlecenta 39 Junior Poster

When I included a dll file into my project, I used:

HMODULE g_hModule = GetModuleHandle( 0 );
	
HRSRC	hRes		= FindResource( g_hModule, MAKEINTRESOURCE( ID_DLL_MYDLL ), "ID_DLL" );
HGLOBAL hResource	= LoadResource( g_hModule, hRes );
DWORD	iResSize	= SizeofResource( g_hModule, hRes );
	
BYTE* pData 		= ( BYTE* )LockResource( hResource );

Once its loaded into memory I use:

fstream pFile( ".\\My Dll.dll", ios::out );
	
pFile.write( ( const char* )pData, iResSize );
	
pFile.close();

So that It creates the dll outside of the executable at run time.

But ive noticed that the dll fails to be properly written and the file size is out of sync

2.04 MB (2,145,280 bytes) For original dll

2.04 MB (2,146,101 bytes) For the dll that was written

What could be causing this?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.