Hi all,
I'm stuck and hope someone out there knows how to get around this.
I have to interface with a 3rd party vendor win32 dll and on one of
their calls, they are returning a bunch of data from a scanned image.
There could be chr(0)'s, etc.... The format they have setup for the
returned data is really funky. Bytes 2-5 is the length of the entire
message. I'm trying to receive it into my vb.net app, but am only
getting partial data back, I'm assuming it's because of the chr(0)
etc...
How do you declare the function in order to receive all the bytes they
are sending. Maybe, I just dont have it setup right.
Here is there exported method:
int WINAPI GetTheData (char *msg, int *Length)
This is the way I have it declared:
Declare Function GetTheData Lib "scandll.dll" (ByVal msg As
StringBuilder, ByRef msgLength As IntPtr) As Integer
I was using a StringBuilder because I thought it was all char data,but
like I said, there could be chr(0)'s in it. Not only am I having a
problem with the msg data itself, but the length when I print it using
msgLength.ToInt32 doesn't seem right either, so I'm not sure if I have
that defined correctly either. For example, when I run their demo, the
length is displayed as 204430, but when I display the IntPtr.ToInt32, I
get 42. The demo code they supplied is in C++ so it doesn't have this
issue, but I need this in vb.net.
Any help would be most appreciated.
Thanks,
Mark 7 1606
I would try a byte array for a start...
--
Patrice
<ma*****@yahoo.com> a écrit dans le message de
news:11**********************@g49g2000cwa.googlegr oups.com... Hi all,
I'm stuck and hope someone out there knows how to get around this.
I have to interface with a 3rd party vendor win32 dll and on one of their calls, they are returning a bunch of data from a scanned image. There could be chr(0)'s, etc.... The format they have setup for the returned data is really funky. Bytes 2-5 is the length of the entire message. I'm trying to receive it into my vb.net app, but am only getting partial data back, I'm assuming it's because of the chr(0) etc...
How do you declare the function in order to receive all the bytes they are sending. Maybe, I just dont have it setup right.
Here is there exported method: int WINAPI GetTheData (char *msg, int *Length)
This is the way I have it declared: Declare Function GetTheData Lib "scandll.dll" (ByVal msg As StringBuilder, ByRef msgLength As IntPtr) As Integer
I was using a StringBuilder because I thought it was all char data,but like I said, there could be chr(0)'s in it. Not only am I having a problem with the msg data itself, but the length when I print it using msgLength.ToInt32 doesn't seem right either, so I'm not sure if I have that defined correctly either. For example, when I run their demo, the length is displayed as 204430, but when I display the IntPtr.ToInt32, I get 42. The demo code they supplied is in C++ so it doesn't have this issue, but I need this in vb.net.
Any help would be most appreciated.
Thanks, Mark
Inline
<ma*****@yahoo.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com... Hi all,
I'm stuck and hope someone out there knows how to get around this.
I have to interface with a 3rd party vendor win32 dll and on one of their calls, they are returning a bunch of data from a scanned image. There could be chr(0)'s, etc.... The format they have setup for the returned data is really funky. Bytes 2-5 is the length of the entire message. I'm trying to receive it into my vb.net app, but am only getting partial data back, I'm assuming it's because of the chr(0) etc...
How do you declare the function in order to receive all the bytes they are sending. Maybe, I just dont have it setup right.
Here is there exported method: int WINAPI GetTheData (char *msg, int *Length)
This is the way I have it declared: Declare Function GetTheData Lib "scandll.dll" (ByVal msg As StringBuilder, ByRef msgLength As IntPtr) As Integer
Change msgLength to be an Integer rather than an IntPtr.
Regards,
Nick Hall
What would the declare look like to receive it as a byte array ?
The other advice is also good (ie int * is a pointer on an integer that is
"ByRef Length as Integer").
Mine is based on char * begin AFAIK often used as a byte array (and as this
is scanner image, it is much more lokemy somethjng you'll want to handle as
a byte array rather than as a string)... So I would say it translates to
ByRef msg() As Byte.
You may have also :
- to call first this one with some kind of overload attributes to get first
the actual buffer size you need, posisbly using an addtional overload.
- imo Marhshalling attributes should allow to have an even cleaner signature
(AFAIK one allows to pass an array taken automatically into account the size
?)
--
Patrice
<ma*****@yahoo.com> a écrit dans le message de
news:11**********************@o13g2000cwo.googlegr oups.com... What would the declare look like to receive it as a byte array ?
I was hoping someone could help out on the marshalling attributes of
the dllimport. I'm not that familiar with it. As far as the msglen
field, I tried byref as integer and byval as integer. byval it didn't
like at all and byref did nothing different from when I had it as a
IntPtr. Most of the time its ok, its only these messages I get with
the image data.
Thanks.
More explicitely, the simplest form I would try for a start is :
Declare Function GetTheData Lib "scandll.dll" (ByVal msg() As Byte,ByRef
msgLength As Integer) As Integer
Does it work ? Now :
- call this function with a small array, the function should return a code
that tells that it doesn't work and you should have in msgLength the number
of bytes needed
- now you can call this function with an array that is big enough and the
function should return a code saying it's ok
I hope it works or that someone else will be able to give you a better
help...
--
Patrice
<ma*****@yahoo.com> a écrit dans le message de
news:11**********************@g49g2000cwa.googlegr oups.com... I was hoping someone could help out on the marshalling attributes of the dllimport. I'm not that familiar with it. As far as the msglen field, I tried byref as integer and byval as integer. byval it didn't like at all and byref did nothing different from when I had it as a IntPtr. Most of the time its ok, its only these messages I get with the image data.
Thanks.
Thanks.
I think I got it to receive the byte array (at least I can look at the
bytes), although the length still shows only 42. I'll keep banging
away on it. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: zardoz |
last post by:
I've got this problem:
unsigned long long lTemp;
char cLargeNum="1324567890";
sscanf(clargeNum,"%llu",&lTemp);
which under Win32 isn't working*. My program needs to compile under
posix so...
|
by: CptDondo |
last post by:
I am working on an embedded platform which has a block of battery-backed
RAM. I need to store various types of data in this block of memory -
for example, bitmapped data for control registers,...
|
by: _R |
last post by:
I've had to write a lot of code to interface C# to older Win32 DLLs.
Basically, an unmanaged C++ class talks directly to the Win32 DLL.
A managed C++ class encloses the unmanaged C++ class.
C#...
|
by: Danny |
last post by:
I am working on a project in which a number of client applications will be
posting xml documents as a byte array to an ASP.NET page on our web server. I
am trying to simulate the process and run...
|
by: _iycrd |
last post by:
Specifically I need to wrap an older Win32 DLL in a managed class. I
had this running with VS2003's Managed Extensions, though it required
two separate classes.
With C++/CLI this was supposed...
|
by: cman |
last post by:
What do pointers to pointers accomplish? How does having a pointer to
a pointer help a design or aglorithm? Where are they normally used?
cman
|
by: Boris |
last post by:
I had a 3 hours meeting today with some fellow programmers that are partly
not convinced about using smart pointers in C++. Their main concern is a
possible performance impact. I've been explaining...
|
by: googlinggoogler |
last post by:
Hi
This should all be pretty standard C stuff, but I'm going to use terms
like mouse callback to communicate what Im tyring to do.
Basically I have my program whirling around in an infinite...
|
by: pateldm15 |
last post by:
How do I sort an string array using pointers
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
| |