A
Angel
Hi again,
I'm trying to call functions from a proprietary DLL but it's turned out to
be more difficult than I thought.
I have this W32.DLL which was written in C by USPS. They don't provide the
code so I only have the documentation.
I'm trying to call a function called z4date that, according to the docs,
returns the date as "an 8-byte character string in the "YYYYMMDD" format".
When I run it with this code I've written , I get "Can not marshal return
value".
My real concern is that, if I'm having trouble with these functions that
return simple data types, how am I going to interact with functions that
return user-defined data types?
This is what I've written in the class so far:
....
using System.Runtime.InteropServices;
namespace ZM7
{
/// <summary>
/// Summary description for AMS.
/// </summary>
public class AMS
{
[DllImport("C:\\zm7\\Developm\\DLL\\W32.DLL")]
public static extern int z4open(); //another function from the dll
[DllImport("C:\\zm7\\Developm\\DLL\\W32.DLL")] /* Do I need to use
DllImport for every fiunction I'm using? */
public static extern byte[] z4date();
....
public byte[] getDate()
{
Byte[] myDate;
myDate = new Byte[8];
myDate = z4date(); //function call where I receive error "Can not
marshal return value"
return myDate();
}
Any help is appreciated.
I'm trying to call functions from a proprietary DLL but it's turned out to
be more difficult than I thought.
I have this W32.DLL which was written in C by USPS. They don't provide the
code so I only have the documentation.
I'm trying to call a function called z4date that, according to the docs,
returns the date as "an 8-byte character string in the "YYYYMMDD" format".
When I run it with this code I've written , I get "Can not marshal return
value".
My real concern is that, if I'm having trouble with these functions that
return simple data types, how am I going to interact with functions that
return user-defined data types?
This is what I've written in the class so far:
....
using System.Runtime.InteropServices;
namespace ZM7
{
/// <summary>
/// Summary description for AMS.
/// </summary>
public class AMS
{
[DllImport("C:\\zm7\\Developm\\DLL\\W32.DLL")]
public static extern int z4open(); //another function from the dll
[DllImport("C:\\zm7\\Developm\\DLL\\W32.DLL")] /* Do I need to use
DllImport for every fiunction I'm using? */
public static extern byte[] z4date();
....
public byte[] getDate()
{
Byte[] myDate;
myDate = new Byte[8];
myDate = z4date(); //function call where I receive error "Can not
marshal return value"
return myDate();
}
Any help is appreciated.