Click here to Skip to main content
15,913,722 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: CEdit question Pin
David Crow5-Nov-02 9:31
David Crow5-Nov-02 9:31 
GeneralRe: CEdit question Pin
valikac5-Nov-02 10:08
valikac5-Nov-02 10:08 
GeneralRe: CEdit question Pin
David Crow6-Nov-02 3:59
David Crow6-Nov-02 3:59 
GeneralSystem Image list Pin
Stefan Bolder5-Nov-02 5:55
sussStefan Bolder5-Nov-02 5:55 
GeneralRe: System Image list Pin
Gary R. Wheeler5-Nov-02 10:55
Gary R. Wheeler5-Nov-02 10:55 
GeneralSave a File from Variant Pin
Jose Fco Bonnin5-Nov-02 5:40
Jose Fco Bonnin5-Nov-02 5:40 
GeneralRe: Save a File from Variant Pin
TyMatthews5-Nov-02 6:25
TyMatthews5-Nov-02 6:25 
GeneralRe: Save a File from Variant Pin
dabs5-Nov-02 9:07
dabs5-Nov-02 9:07 
Assuming you have the variant containing the data then this function will extract the data and put it into *ppBuf:

<br />
bool GetBinaryFromVariant( VARIANT& vData, BYTE ** ppBuf, unsigned long * pcBufLen )<br />
{<br />
	bool bReturn = false;<br />
<br />
	//Binary data is stored in the variant as an array of unsigned char<br />
	if( vData.vt == ( VT_ARRAY|VT_UI1 ) )<br />
	{<br />
		//Retrieve size of array<br />
		*pcBufLen = vData.parray->rgsabound[0].cElements;<br />
<br />
		//Allocate a buffer to store the data<br />
		*ppBuf = new BYTE[*pcBufLen]; <br />
		<br />
		if(*ppBuf != NULL)<br />
		{<br />
			void* pArrayData;<br />
			//Obtain safe pointer to the array<br />
			SafeArrayAccessData(vData.parray,&pArrayData);<br />
<br />
			//Copy the bitmap into our buffer<br />
			memcpy(*ppBuf, pArrayData, *pcBufLen);<br />
<br />
			//Unlock the variant data<br />
			SafeArrayUnaccessData(vData.parray);<br />
			bReturn = true;<br />
		}<br />
	}<br />
	<br />
	return bReturn;<br />
}<br />


Then you would use it like this - the code is from the top of my head so I'm not sure it will compile or work correctly Smile | :)

<br />
<br />
BYTE* pBuffer = NULL;<br />
UINT nBufSize = 0;<br />
if ( GetBinaryFromVariant( vtJPEG, &pBuffer, &nBufSize ) )<br />
{<br />
  //Safe the buffer to file:<br />
  CFile file;<br />
  if ( file.Open( strTheFileName, CFile::modeCreate | CFile::modeTruncate ) )<br />
  {<br />
    file.Write( pBuffer, nBufSize );<br />
  }<br />
  delete [] pBuffer;<br />
}<br />





Wenn ist das Nunstück git und Slotermeyer? Ja! Beierhund das oder die Flipperwaldt gersput!
GeneralVisual Studio Installer and drivers installation Pin
Susy B.5-Nov-02 5:34
sussSusy B.5-Nov-02 5:34 
GeneralPlease help with networking solutions Pin
Walote5-Nov-02 5:22
Walote5-Nov-02 5:22 
GeneralRe: Please help with networking solutions Pin
valikac5-Nov-02 8:33
valikac5-Nov-02 8:33 
GeneralSerialization question Pin
ns5-Nov-02 5:25
ns5-Nov-02 5:25 
GeneralRe: Serialization question Pin
Ravi Bhavnani5-Nov-02 6:06
professionalRavi Bhavnani5-Nov-02 6:06 
GeneralRe: Serialization question Pin
ns5-Nov-02 6:09
ns5-Nov-02 6:09 
GeneralHelp with ToolTips Pin
Aaron Schaefer5-Nov-02 5:00
Aaron Schaefer5-Nov-02 5:00 
GeneralGetSafeHwnd() Pin
ns5-Nov-02 4:53
ns5-Nov-02 4:53 
GeneralRe: GetSafeHwnd() Pin
TyMatthews5-Nov-02 6:14
TyMatthews5-Nov-02 6:14 
GeneralRe: GetSafeHwnd() Pin
ns5-Nov-02 6:17
ns5-Nov-02 6:17 
GeneralRe: GetSafeHwnd() Pin
Ravi Bhavnani5-Nov-02 7:32
professionalRavi Bhavnani5-Nov-02 7:32 
GeneralRe: GetSafeHwnd() Pin
ns5-Nov-02 7:36
ns5-Nov-02 7:36 
GeneralRe: GetSafeHwnd() Pin
Ravi Bhavnani5-Nov-02 7:57
professionalRavi Bhavnani5-Nov-02 7:57 
GeneralSQL Wildcard Search Pin
Richard Hudson5-Nov-02 4:47
Richard Hudson5-Nov-02 4:47 
GeneralRe: SQL Wildcard Search Pin
Pete Bassett5-Nov-02 5:48
Pete Bassett5-Nov-02 5:48 
GeneralRe: SQL Wildcard Search Pin
Jon Hulatt5-Nov-02 5:43
Jon Hulatt5-Nov-02 5:43 
GeneralRe: SQL Wildcard Search Pin
Member 15922365-Nov-02 7:53
Member 15922365-Nov-02 7:53 

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.