Capt Laser Man
2008-12-03 04:14:36 UTC
I have two methods I need to call in a Delphi DLL. They are bother pretty
simple but I am getting access errors so I must be doing something wrong.
The first function and documentation is:
function MLParams(h: word; c: word; p: PChar): boolean; stdcall;
p is a pointer to a Params structure
Params= packed record
size: word;
pointrate: longint;
invertblanking: boolean;
end;
size is the size in bytes of the complete structure.
The second is:
function MLDraw(h, c: word; d: PChar; n: integer): boolean; stdcall;
For a frame oriented device (Riya PCI Pro for example) this function is
called for each frame.
D is a pointer to an array with n points
Point= packed record
x,y,z: word;
r,g,b: byte;
reserved1, reserved2, reserved3: byte;
intensity, reserved4, repeatpoint: byte;
end;
I defined my functions as:
[DllImport(@".\drivers\EasyLase.mld")]private static extern bool
MLDraw(ushort handle, ushort c, LaserPoint[] dataPointer, int size);
[DllImport(@".\drivers\EasyLase.mld")]private static extern bool
MLParams(int handle, int c, ref Params mlParams);
[StructLayout(LayoutKind.Sequential, Pack = 1)]
struct Params
{
public ushort size;
public int pointRate;
public bool invertBlanking;
}
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct LaserPoint
{
public ushort x;
public ushort y;
public byte r;
public byte g;
public byte b;
public byte reserved1;
public byte reserved2;
public byte reserved3;
public byte intensity;
public byte reserved4;
public byte repeatpoint;
}
Do you see anything wrong? Sorry about the weird spacing. That happened
when I copied and pasted and I couldn't make the double spacing go away.
Thanks,
Gary
simple but I am getting access errors so I must be doing something wrong.
The first function and documentation is:
function MLParams(h: word; c: word; p: PChar): boolean; stdcall;
p is a pointer to a Params structure
Params= packed record
size: word;
pointrate: longint;
invertblanking: boolean;
end;
size is the size in bytes of the complete structure.
The second is:
function MLDraw(h, c: word; d: PChar; n: integer): boolean; stdcall;
For a frame oriented device (Riya PCI Pro for example) this function is
called for each frame.
D is a pointer to an array with n points
Point= packed record
x,y,z: word;
r,g,b: byte;
reserved1, reserved2, reserved3: byte;
intensity, reserved4, repeatpoint: byte;
end;
I defined my functions as:
[DllImport(@".\drivers\EasyLase.mld")]private static extern bool
MLDraw(ushort handle, ushort c, LaserPoint[] dataPointer, int size);
[DllImport(@".\drivers\EasyLase.mld")]private static extern bool
MLParams(int handle, int c, ref Params mlParams);
[StructLayout(LayoutKind.Sequential, Pack = 1)]
struct Params
{
public ushort size;
public int pointRate;
public bool invertBlanking;
}
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct LaserPoint
{
public ushort x;
public ushort y;
public byte r;
public byte g;
public byte b;
public byte reserved1;
public byte reserved2;
public byte reserved3;
public byte intensity;
public byte reserved4;
public byte repeatpoint;
}
Do you see anything wrong? Sorry about the weird spacing. That happened
when I copied and pasted and I couldn't make the double spacing go away.
Thanks,
Gary