|
-
February 5th, 2007, 04:47 PM
#1
[RESOLVED] Copymem API Error - wierd one ????
Now this is a very wierd problem...
Code:
Private Block As String
Private File_Block As Long
Private Sub MoveData ()
Dim arr_dat() As Byte
Get_Data () ' Function that returns 1024 bytes in Arr_dat..
File_block = 1024
Block = Space(1024)
CopyMemory Block, arr_dat(0), File_Block ' this now shuts down the IDE...
End Sub
the CopyMemory API causes the ide to exit ...
I'm trying to move and array of binary data into a string without resorting to a loop... And this one has me going mad...
Any Advice ???
Gremmy....
Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
WPF Articles : 3D Animation 1 , 2 , 3
Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.
-
February 5th, 2007, 05:08 PM
#2
Re: Copymem API Error - wierd one ????
Use this:
StringVariable = StrConv(ByteArray, vbUnicode)
-
February 5th, 2007, 05:15 PM
#3
Re: Copymem API Error - wierd one ????
well, each character of a string is two bytes, not one - so the string has to be half the size of the byte array. You also need to pass the memory location of the String's byte array, rather than the BSTR:
Code:
Block = Space(1024 \ 2)
CopyMemory ByVal StrPtr(Block), arr_dat(0), File_Block
that now won't crash your IDE, but it may not be what you're intending to achieve. You may want what logophobic posted, or perhaps even a simple:might achieve your needs...
-
February 5th, 2007, 09:26 PM
#4
Re: Copymem API Error - wierd one ????
or you may just specify byval to the string variable (Block).
CopyMemory ByVal Block, arr_dat(0), File_Block
Busy 
-
February 6th, 2007, 01:51 AM
#5
Re: Copymem API Error - wierd one ????
 Originally Posted by Logophobic
Use this:
StringVariable = StrConv(ByteArray, vbUnicode)
Thanks LogoPhobic...
This works great .. Duno why i didn't remember the function....
Reps when i can give again...
Gremmy
Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
WPF Articles : 3D Animation 1 , 2 , 3
Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.
-
February 6th, 2007, 07:14 AM
#6
-
February 6th, 2007, 02:33 PM
#7
Re: Copymem API Error - wierd one ????
Thread1..
I have it declared the same way..
Code:
Public Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
And for some reason it closes the IDE down - No error msg, no nothing...
Dunno why.. at a later stage i will look at it again and try it again..
Gremmy...
Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
WPF Articles : 3D Animation 1 , 2 , 3
Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.
-
February 6th, 2007, 10:02 PM
#8
Re: Copymem API Error - wierd one ????
ok.. let me say the word again "weird" .. yeah that's weird
Busy 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|