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.dl l" (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.ToInt 32 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 1620
I would try a byte array for a start...
--
Patrice
<ma*****@yahoo. com> a écrit dans le message de
news:11******** **************@ g49g2000cwa.goo glegroups.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.dl l" (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.ToInt 32 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.goo glegroups.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.dl l" (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.goo glegroups.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.dl l" (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.goo glegroups.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 no Win32 specials allowed....
|
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, strings for logging,
and structures for data points.
I want to use one function to read data from this block and one function
to write data, for example:
sram_read(OBJECT_IDENTIFIER) would return a pointer to the appriate
object and
|
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# talks to the managed C++ class.
Lots of work. Is this simplified in C++/CLI? Any sample code
anywhere?
|
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 into problems.
Sending code:
ASCIIEncoding encoding = new ASCIIEncoding();
string lcUrl = "http://localhost/test/receive.aspx";
HttpWebRequest loHttp =
|
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 to be simple, right? I had thought
that the new C++/CLI syntax was supposed to allow mixing of
managed/unmanaged in the same class but I'm running into quite a few
snags.
I'm sure the problems are commonplace, so rather than listing tons of
| |
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 the advantages of smart
pointers endlessly (which are currently used in all our C++ software; we
use the Boost smart pointers) as I'm seriously concerned that there is a
shift to raw pointers. We are not developing system software but rather...
|
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 loop (easy)
waiting for the mouse to be clicked (I dont need help with this) and
depending on user input a variable might define what function I want
(be it line, circle....(again these are my issues)
|
by: pateldm15 |
last post by:
How do I sort an string array using pointers
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |