P
Peter Gloor
Hello NG,
I have a mirror.dll written in C I would like to access from a C# console
application. However, I dont't know how to to it.
The dll is fairly well documented and I have access to the header files.
According to the documentation and the header files the function I need is
declared as follows:
extern "C" {
unsigned short far pascal InitMirror( int argc, char far * far *argv);
}
argc: # command line arguments the program was invoked with.
argv: pointer to an array of far pointers to null-terminated character
strings that contain the arguments the program was invoked with.
Returns zero if successfull, or a non-zero value if unable to initialize.
Now, I'm doing someting wrong, so my code always returns a non-zero value.
using System;
using System.Runtime.InteropServices;
namespace MirrorDemo
{
class Demo {
[DllImport("mirror.dll", EntryPoint="InitMirror",
SetLastError=false, CharSet=CharSet.Ansi, ExactSpelling=true,
CallingConvention=CallingConvention.StdCall)]
public static extern int InitMirror(int argc, String [] argv);
[STAThread]
static void Main(string[] args) {
int error;
error = InitMirror(args.Length, args);
if (error != 0) {
Console.WriteLine("Error: {0}", error);
}
}
}
}
This doesn't work as I already expected. However I dont't know how to do it.
How should the code look like?
Any hints are welcome!
Thanks in advance.
Peter Gloor
I have a mirror.dll written in C I would like to access from a C# console
application. However, I dont't know how to to it.
The dll is fairly well documented and I have access to the header files.
According to the documentation and the header files the function I need is
declared as follows:
extern "C" {
unsigned short far pascal InitMirror( int argc, char far * far *argv);
}
argc: # command line arguments the program was invoked with.
argv: pointer to an array of far pointers to null-terminated character
strings that contain the arguments the program was invoked with.
Returns zero if successfull, or a non-zero value if unable to initialize.
Now, I'm doing someting wrong, so my code always returns a non-zero value.
using System;
using System.Runtime.InteropServices;
namespace MirrorDemo
{
class Demo {
[DllImport("mirror.dll", EntryPoint="InitMirror",
SetLastError=false, CharSet=CharSet.Ansi, ExactSpelling=true,
CallingConvention=CallingConvention.StdCall)]
public static extern int InitMirror(int argc, String [] argv);
[STAThread]
static void Main(string[] args) {
int error;
error = InitMirror(args.Length, args);
if (error != 0) {
Console.WriteLine("Error: {0}", error);
}
}
}
}
This doesn't work as I already expected. However I dont't know how to do it.
How should the code look like?
Any hints are welcome!
Thanks in advance.
Peter Gloor