Code: Show/Hide Option Explicit '[..] Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory"_ (Dest As Any, Src As Any, ByVal cb&) '[..] Public Function StringToLong(data As String) As Long Dim output As Long Call CopyMemory(output, ByVal data, 4) StringToLong = output End Function Public Function LongToString(data As Long) As String Dim output As String * 4 Call CopyMemory(output, ByVal data, 4) LongToString = output End Function Public Function StringToInteger(data As String) As Integer Dim output As Integer Call CopyMemory(output, ByVal data, 2) StringToInteger = output End Function Public Function IntegerToString(data As Integer) As String Dim output As String * 2 Call CopyMemory(output, ByVal data, 2) IntegerToString = output End Function |
Mr Ekted wrote: |
It's clear you don't have a clue about BASIC or how software works |
Someone else wrote: |
I use API-function RtlMoveMemory to create the binarysting to be sent over. Private Declare Sub CopyMemory Lib "KERNEL32" Alias "RtlMoveMemory" ( hpvDest As Any, hpvSource As Any, ByVal cbCopy As Long) This is ok at the client side. The server on the other hand does not handle the this correctly. When parsing the string using rtlMoveMemory the server crashes... or give fuzzy results (VB just quits with errors!!??) It seems to me that RtlMoveMemory tries to read a memoryblock that is not readable (because of the General Protection Fault???). |
Someone else wrote: |
Well, I have messed up my project, because I could not find any solution to get things working... |
Mine GO BOOM wrote: |
Can we keep the cursing to a minimum? Also, General Questions are for Server related questions.
-nintendo64 |
nintendo64 wrote: |
[..]
I wouldn't say the problem is VB, it's a human mistake, althought VB is indeed a problem most of the times, as any language that is so high level. If you handle things at the low level, or at least use a high level language that enables you to declare your own pointers, you might have more understanding. Certaintly VB could cause some of the errors, but in the functions you need i don't see why, try what i said. -nintendo64 |
Mr Ekted wrote: |
ByVal is not a protection mechanism. It is the newb way to say "by value" instead of "by address". In C it is done explicitly, and you can refer to data in any way you want.
[..] |
Nintendo wrote: |
I wouldn't say the problem is VB, it's a human mistake, althought VB is indeed a problem most of the times, as any language that is so high level. |
Cyan~Fire wrote: |
Acutally, you're right Cyph, maybe Qndre's switched to a higher level language now.
Anyway, if your functions are named correctly, you're trying to convert an ASCII string to an integer? Like "4800" to 0x12C0? If so, then you don't need to copy memory. If you are actually using VisualBasic now, there are the functions CInt() and CLng() that will convert from a string to an integer and long. The = operator will convert from an integer or long to a string for you. |