Xun Hu
April 7th, 1999, 07:49 PM
I'd like to pass a binary data file from component to client, can somebody help me how to implement it?
Thanks.
Thanks.
|
Click to See Complete Forum and Search --> : Binary Data File Xun Hu April 7th, 1999, 07:49 PM I'd like to pass a binary data file from component to client, can somebody help me how to implement it? Thanks. April 13th, 1999, 02:12 PM Make a SafeArray with VT_UI1. Saurabh Dasgupta April 15th, 1999, 04:45 AM Hi, You can add the desired binary file to your COM DLL as a resource file. This would be similar to adding bitmaps,icons,dialog boxes, etc. But in this case your file is a user defined resource type. Let us say "MyBINARY" . Once you have done this you can dump the bytes of this data file at run time, and store it as a file or pass it as an array of charcters to some other function. To get a pointer to a resource data do the following: ///////////////////////////////////////////////////////////////////////////// HRSRC rc = FindResource(hDllInst,lpszResName,lpszResType); //here lpszResName is the name you have given to your binary resource, //eg: "BIN_DATA1" //lpszResType is the type of resource, "MyBINARY" in this case //the module instance handle is hDllInst if (rc == NULL ) return FALSE; HGLOBAL hglb=LoadResource(NULL,rc); if (NULL == hglb) return FALSE; LPVOID lpv=LockResource(hglb); if (lpv == NULL ) return NULL; //you have just got hold of the pointer to the first byte of the resource //Now you need to know the size DWORD size = SizeofResource(NULL,rc); /* Now you have what you want, you can pass the data buffer as an array of bytes along with the size of the array OR dump it to a binary file */ ///////////////////////////////////////////////////////////////////////////// Hope this solves your problem, Regards Saurabh codeguru.com
Copyright Internet.com Inc., All Rights Reserved. |