Click here to Skip to main content
16,008,954 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: registry keys ? Pin
imran_rafique8-Oct-02 17:05
imran_rafique8-Oct-02 17:05 
GeneralRe: registry keys ? Pin
Navin8-Oct-02 17:21
Navin8-Oct-02 17:21 
GeneralDLL Pin
stevenson8-Oct-02 14:46
stevenson8-Oct-02 14:46 
GeneralRe: DLL Pin
Navin8-Oct-02 15:48
Navin8-Oct-02 15:48 
GeneralTCPIP/NDIS driver issue Pin
Jesse Rosalia8-Oct-02 13:33
Jesse Rosalia8-Oct-02 13:33 
GeneralBitmap Pin
Anonymous8-Oct-02 12:56
Anonymous8-Oct-02 12:56 
GeneralRe: Bitmap Pin
Christian Graus8-Oct-02 14:23
protectorChristian Graus8-Oct-02 14:23 
GeneralRe: Bitmap Pin
Paul M Watt8-Oct-02 18:20
mentorPaul M Watt8-Oct-02 18:20 
The GetObject function requires a HBITMAP handle rather than the path to where the image is found. In order to get a HBITMAP handle you will need to load the image into a bitmap object. If you simply want to send the bitmap to another computer via a socket, you do not even need to load the bitmap into a HBITMAP object. This is used for displaying and manipulating the bits of the image.

All that you will need to do is open the file where the image is located, read the file data into memory, then use that memory buffer to send your image across the socket.

Here is an example:
<br />
HANDLE hFile = ::CreateFile("\\Windows\\Start Menu\\front2.bmp", GENERIC_READ, NULL, OPEN_EXISTING, 0, 0);<br />
if (INVALID_HANDLE_VALUE == hFile)<br />
{<br />
// An error occured, your file could not be opened.  It may be in use or you have a wrong path.<br />
}<br />
//Get the Size of the bitmap file.<br />
DWORD FileSize = ::GetFileSize(hFile, NULL);<br />
//Allocate a buffer for the data.<br />
BYTE *pbBuffer = new BYTE[FileSize];<br />
if (!pbBuffer)<br />
{<br />
// The memory allocation failed for your image buffer.<br />
}<br />
//REad the file into your memory buffer.<br />
::ReadFile(hFile, pbBuffer, FileSize, &Bytes, 0);<br />


After you execute that code, pbBuffer will contain all of the data in the bitmap file and you can use that to send it over the socket. After you send it you will need to call delete[] pbBuffer;

Good Luck


Build a man a fire, and he will be warm for a day
Light a man on fire, and he will be warm for the rest of his life!

GeneralRe: Bitmap Pin
Bartosz Bien10-Oct-02 11:24
Bartosz Bien10-Oct-02 11:24 
GeneralHost name from given url Pin
orcun colak8-Oct-02 12:19
orcun colak8-Oct-02 12:19 
GeneralRe: Host name from given url Pin
valikac8-Oct-02 12:44
valikac8-Oct-02 12:44 
GeneralRe: Host name from given url Pin
Jon Sagara8-Oct-02 12:47
Jon Sagara8-Oct-02 12:47 
GeneralRe: Host name from given url Pin
Michael Dunn8-Oct-02 18:51
sitebuilderMichael Dunn8-Oct-02 18:51 
GeneralMaking Autoruns in C++ Pin
CSHighCommand8-Oct-02 11:28
CSHighCommand8-Oct-02 11:28 
GeneralRe: Making Autoruns in C++ Pin
Anonymous8-Oct-02 11:36
Anonymous8-Oct-02 11:36 
GeneralRe: Making Autoruns in C++ Pin
Anonymous8-Oct-02 11:57
Anonymous8-Oct-02 11:57 
GeneralRe: Making Autoruns in C++ Pin
Martin Marvinski8-Oct-02 12:19
Martin Marvinski8-Oct-02 12:19 
GeneralRe: Making Autoruns in C++ Pin
Bill Wilson8-Oct-02 12:56
Bill Wilson8-Oct-02 12:56 
GeneralRe: Making Autoruns in C++ Pin
Jerome Conus8-Oct-02 19:22
Jerome Conus8-Oct-02 19:22 
GeneralRe: Making Autoruns in C++ Pin
Bill Wilson9-Oct-02 7:21
Bill Wilson9-Oct-02 7:21 
GeneralRe: Making Autoruns in C++ Pin
Slayer8-Oct-02 21:10
Slayer8-Oct-02 21:10 
GeneralRe: Making Autoruns in C++ Pin
Patje8-Oct-02 20:57
Patje8-Oct-02 20:57 
GeneralWin32 + mySQL Pin
Anonymous8-Oct-02 11:22
Anonymous8-Oct-02 11:22 
GeneralRe: Win32 + mySQL Pin
Jon Sagara8-Oct-02 11:53
Jon Sagara8-Oct-02 11:53 
GeneralLink problem #2 Pin
algruber8-Oct-02 11:20
algruber8-Oct-02 11:20 

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.