|
|
I have a blob that i retreived in a char* buffer, and it has access header stuff for 78 starting bytes. I want to remove these. whats the simplest way of doing this. I know the total length. i tried:
but it crashes at the memcpy. The pBuf I got from doing :
SafeArrayAccessData(varBLOB.parray,(void **)&pBuf);
Its the first 78 bytes of pBuf I want to get rid of.
Thanks,
ns
|
|
|
|
|
memmove ( pBuf, pBuf+78, DataLength-78 ); You need to use memmove() because the source and dest ranges overlap.
--Mike--
Just released - RightClick-Encrypt v1.3 - Adds fast & easy file encryption to Explorer
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
Gosh! That was like magic!! I couldnt believe it when I used your memmove and my images showed up!!!!I cant thank you enough!!!!!
ns
|
|
|
|
|
I don't think you even need to do that. If you have a char * called szRodney and you want to skip the first four characters, then
char * szEy = szRodney+4;
should do it, just don't forget to delte szRodney and NOT szEy.
Christian
We're just observing the seasonal migration from VB to VC. Most of these birds will be killed by predators or will die of hunger. Only the best will survive - Tomasz Sowinski 29-07-2002 ( on the number of newbie posters in the VC forum )
Cats, and most other animals apart from mad cows can write fully functional vb code. - Simon Walton - 6-Aug-2002
|
|
|
|
|
One way to do it is:
int bytestoskip = 78;<br />
void *pBuf;<br />
SafeArrayAccessData(varBLOB.parray,(void **)&pBuf);<br />
char *szStr = (char *)pBuf + bytestoskip;
Drinking In The Sun
Forgot Password?
|
|
|
|
|
Great! But a nagging question. I'm new to pointers. Now ,I thought that when you declare something as char* you have to do a new to allocate memory before you can use it. Yet in the SafeArrayAccessData and also your *szStr, all we have is the pointer declaration, but no memory allocated for its contents. Sorry if this is an obvious question.
Thanks for the nifty suggestion.
ns
|
|
|
|
|
A SafeArray has the data allocated somewhere in its internal buffer. When you call SafeArrayAccess Data, the interal buffer is locked and a pointer to it is returned to you. This means that you do not have to copy the data, but you'll have to keep the safearray locked. Remember to call SafeArrayUnaccessData when you're done with the pointer!
James
Drinking In The Sun
Forgot Password?
|
|
|
|
|
|
Ok, I work with VB professionally, however I am about to make the jump into working on a possible project using MFC (applaud later ). I know this may sound like a dumb question but if I wanted to have a button show what a dialog window to open a file I know in VB we use the CommonDialog component. What do you do for MFC? I was looking around and I can see that you can insert a resource but that wasn't very clear to me. Can someone point me in the right direction, thanks in advance?
Nick Parker
|
|
|
|
|
|
Michael Dunn wrote:
I think you're talking about the standard file open dialog? MFC has CFileDialog.
Thanks Mike,
That's exactly what I was looking for.
I tried to do
CFileDialog cf;
cf.ShowWindow();
but I get an error saying "'CFileDialog' : no appropriate default constructor available"
Nick Parker
|
|
|
|
|
RTFM
The CFileDialog constructor has one manadatory parameter, a BOOL indicating whether it's for opening (TRUE) or saving (FALSE). So something like:
CFileDialog dlg ( TRUE );
if ( IDOK == dlg.DoModal() )
{
CString sSelectedFile = dlg.GetPathName();
} You use DoModal() to show a modal dialog.
--Mike--
Just released - RightClick-Encrypt v1.3 - Adds fast & easy file encryption to Explorer
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
Crap! You type faster than me!
|
|
|
|
|
Michael Dunn wrote:
RTFM
Which one do you suggest, really? I will give it a try.
Thanks Mike, hopefully I won't get stuck so quickly next time.
Nick Parker
|
|
|
|
|
Just put the cursor on the word CFileDialog, then hit F1 to jump right to the MSDN page on the class.
--Mike--
Just released - RightClick-Encrypt v1.3 - Adds fast & easy file encryption to Explorer
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
WEll, you need to use the non-default constructor.
This is from MSDN.
CFileDialog( BOOL bOpenFileDialog, LPCTSTR lpszDefExt = NULL, LPCTSTR lpszFileName = NULL, DWORD dwFlags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, LPCTSTR lpszFilter = NULL, CWnd* pParentWnd = NULL );
so, CFileDialog cf(TRUE); will give you a default Open File dialog.
So you were on the right track.
MSDN is very helpful with this kind of information (either online or integrated into VisualStudio).
Hope this helps!
|
|
|
|
|
I want to realize the effect like Book page turning (flip),How can I make it,
where can I find a sample code ,thanks a lot!
|
|
|
|
|
I used LeadTools[^] for this. Their library is pretty cool. They have quite a few other transitions too.
/ravi
Let's put "civil" back into "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
But I want the VC source code which can help me to make it,where can I find it?
|
|
|
|
|
If it was easy and commonly available then Leadtools would not be making a quid out of it, would they ?
Christian
We're just observing the seasonal migration from VB to VC. Most of these birds will be killed by predators or will die of hunger. Only the best will survive - Tomasz Sowinski 29-07-2002 ( on the number of newbie posters in the VC forum )
Cats, and most other animals apart from mad cows can write fully functional vb code. - Simon Walton - 6-Aug-2002
|
|
|
|
|
that's the trouble with a site like this ... people get spoiled
-c
WWJD? JWRTFM. found on /.
|
|
|
|
|
Jesus Would Read The Fxxxxx Manual ?
Christian
We're just observing the seasonal migration from VB to VC. Most of these birds will be killed by predators or will die of hunger. Only the best will survive - Tomasz Sowinski 29-07-2002 ( on the number of newbie posters in the VC forum )
Cats, and most other animals apart from mad cows can write fully functional vb code. - Simon Walton - 6-Aug-2002
|
|
|
|
|
yep. cause Jesus wasn't dumb.
-c
WWJD? JWRTFM. found on /.
|
|
|
|
|
Hi -
Does anyone know how to change the browser mouse cursor for a item when the mouse goes over it, I need to have a custom cursor that looks like any image I want for when the mouse goes over it for IE 5.5. I want to program a small activeX style plug-in which can change the mouse cursor. Any idea how to do this?
Cheers, Phil
|
|
|
|