ianouii
asked on
String Handling in VB .Net
I have a fine working code in VB6 which goes like this:
Dim strPhoto As String
strPhoto = Space(4000)
nResult = Read_Photo(strPhoto)
which the strPhoto reads out an image file contents in binary format.
Note: Read_Photo is an API call.
as when I convert this to VB .Net, the strPhoto reading can't take in the correct binary format.
any idea? Pls advise.
Dim strPhoto As String
strPhoto = Space(4000)
nResult = Read_Photo(strPhoto)
which the strPhoto reads out an image file contents in binary format.
Note: Read_Photo is an API call.
as when I convert this to VB .Net, the strPhoto reading can't take in the correct binary format.
any idea? Pls advise.
ASKER
I think u misunderstood. The API calls to return the binary string is a fixed function where I can't change that....
Rite now, I need the solution to manipulate the string in VB .Net just like how it react in VB6.
tqvm.
Rite now, I need the solution to manipulate the string in VB .Net just like how it react in VB6.
tqvm.
Hi ,
what kind of argument Read_Photo takes. just string ?
What Read_Photo(strPhoto) is giving you ?
-Baan
what kind of argument Read_Photo takes. just string ?
What Read_Photo(strPhoto) is giving you ?
-Baan
DId you change your API for using in .NET
Long will become Integer
Any will become Object
Long will become Integer
Any will become Object
ASKER
Read_Photo(string) is a fixed API which is directly given by the hardware provider where we can't change anything to it. It's only expecting string input.
the string will be filled up with all the binary info once the Read_Photo function successfully executed.
tqvm.
the string will be filled up with all the binary info once the Read_Photo function successfully executed.
tqvm.
So, when you do this... nResult = Read_Photo(strPhoto)
What's it giving you ?
-Baan
What's it giving you ?
-Baan
ASKER
the nResult will just return successful code.
but the strPhoto will return big junk of binary info of a jpg format photos.
I'll then need to put that into a file by using the fileopen command in VB .net
let's concentrate in getting the string done to get the proper info.
tqvm.
but the strPhoto will return big junk of binary info of a jpg format photos.
I'll then need to put that into a file by using the fileopen command in VB .net
let's concentrate in getting the string done to get the proper info.
tqvm.
So you are concerned about "strPhoto = Space(4000)" , right ?
-Baan
-Baan
Do you think the problem is with the size ? try making the size bigger, lets see what happens.
ASKER
I've made the space(500000)
still, it doesn't work.
still, it doesn't work.
I think what Iouri was alluding to, what is your API defined as:
Bob
Bob
Long in VB.NET is a 64-bit number, while Integer is a 32-bit number. In defining the API declaration, you need to keep that in mind.
Bob
Bob
ASKER
It has nothing with the nResult.
The API declared can't be changed as it's provided by the hardware manufacturer.
The driver provider is set to take string input only.
The API declared can't be changed as it's provided by the hardware manufacturer.
The driver provider is set to take string input only.
Okay, let's try it one more time. Can you post your API declaration for us to see (both the VB6 and VB.NET declarations), please?
Thanks,
Bob
Thanks,
Bob
ASKER
VB6.
Declare Function Read_Photo Lib "gsdk.dll" Alias "_Read_Photo@4" (ByVal pbPhoto As String) As Integer
VB .Net
Declare Function Read_Photo Lib "gsdk.dll" Alias "_Read_Photo@4" (ByVal pbPhoto As String) As Integer
Declare Function Read_Photo Lib "gsdk.dll" Alias "_Read_Photo@4" (ByVal pbPhoto As String) As Integer
VB .Net
Declare Function Read_Photo Lib "gsdk.dll" Alias "_Read_Photo@4" (ByVal pbPhoto As String) As Integer
Yes, in this case there is nothing to change. But if it were declared as Long, you shoud've declared it as integer
ASKER
any resolution?
Actually, what kind of string does ReadPhoto take?
ASKER
just a normal string....
You might need to use the MarshalAsAttribute:
<MarshalAs(UnmanagedType.L PWStr)>
Declare Auto Function Read_Photo Lib "gsdk.dll" Alias "_Read_Photo@4" (ByVal pbPhoto As <MarshalAs(UnmanagedType.L PWStr)>Str ing) As Integer
Bob
<MarshalAs(UnmanagedType.L
Declare Auto Function Read_Photo Lib "gsdk.dll" Alias "_Read_Photo@4" (ByVal pbPhoto As <MarshalAs(UnmanagedType.L
Bob
What kind of class it gsdk.dll?
Bob
Bob
ASKER
pls explain further over what're the info u wanna obtain?
the gsdk.dll exposed the API calls for Read_Photo...
the gsdk.dll exposed the API calls for Read_Photo...
Is gsdk.dll a C++ program, VB6 dll, ...?
Bob
Bob
ASKER
I think it's a C++ program.
not very sure about this.
not very sure about this.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
http://www.dotnet4all.com/Dot-Net-Books/2004/08/read-binary-file.html