Thread View: comp.lang.pascal.delphi.misc
2 messages
2 total messages
Started by Martin
Fri, 14 Jan 2005 10:38
Access violation masc.dll
Author: Martin
Date: Fri, 14 Jan 2005 10:38
Date: Fri, 14 Jan 2005 10:38
57 lines
2789 bytes
2789 bytes
Hi,
I'm writing an application to test Mobitex and the MASC protocol. I've
decided to use an dll(masc.dll). The MASC DLL is a Windows DLL that
implements the MASC protocol, allowing applications that have no
knowledge of MASC to communicate with Mobitex modems.
I'm using Delphi and has converted masc.h (written in C/C++) to
delphicode. When I call a method I get the following message: 'Access
violation att address 10001029 in module masc.dll'. Read of address
00000000'.
This is the method I tried to call
Defintion in masc.h
EXPORT int CALLBACK MASC_Open(HMASC* hMASC, char* address,
MASC_SETTINGS* settings, unsigned long timeout);
Definition in Delphi
function MASC_Open(hMASC :HMASC; address: PChar;
settings:MASC_SETTINGS; Timeout: LongInt):integer; cdecl; external
MASCDLL;
My call to MASC_Open in the code:
status := MASC_Open(hMasc, address, settings, 0);
Declaration HMASC, MASC_SETTINGS
HMASC: In masc.h typedef void*
in delphi HMASC=pointer;
MASC_SETTINGS In masc.h typedef struct
{
unsigned int frameQueueSize;
unsigned int commandQueueSize;
unsigned int mpakQueueSize;
}
in delphi type
MASC_SETTINGS = record
frameQueueSize :cardinal;
mpakQueueSize :cardinal;
commandQueueSize :cardinal;
end{MASC_SETTINGS};
I'm not very familiar with c/c++ and pointers so I wouldn't be
surprised if the explanation to the "access violation" lies in the
conversion of different data types and pointers.
Please help if you can, I'm stuck...
Martin
pointers from c/c++ to delphi.
Re: Access violation masc.dll
Author: DaveTV
Date: Sun, 16 Jan 2005 04:19
Date: Sun, 16 Jan 2005 04:19
72 lines
3820 bytes
3820 bytes
Martin wrote:
> Hi,
>
> I'm writing an application to test Mobitex and the MASC protocol. I've
> decided to use an dll(masc.dll). The MASC DLL is a Windows DLL that
> implements the MASC protocol, allowing applications that have no
> knowledge of MASC to communicate with Mobitex modems.
>
> I'm using Delphi and has converted masc.h (written in C/C++) to
> delphicode. When I call a method I get the following message: 'Access
> violation att address 10001029 in module masc.dll'. Read of address
> 00000000'.
>
>
> This is the method I tried to call
>
> Defintion in masc.h
>
> EXPORT int CALLBACK MASC_Open(HMASC* hMASC, char* address,
> MASC_SETTINGS* settings, unsigned long timeout);
>
> Definition in Delphi
>
> function MASC_Open(hMASC :HMASC; address: PChar;
> settings:MASC_SETTINGS; Timeout: LongInt):integer; cdecl; external
> MASCDLL;
>
> My call to MASC_Open in the code:
>
> status := MASC_Open(hMasc, address, settings, 0);
>
> Declaration HMASC, MASC_SETTINGS
>
> HMASC: In masc.h typedef void*
> in delphi HMASC=pointer;
>
> MASC_SETTINGS In masc.h typedef struct
> {
> unsigned int frameQueueSize;
> unsigned int commandQueueSize;
> unsigned int mpakQueueSize;
> }
> in delphi type
> MASC_SETTINGS = record
>
> frameQueueSize :cardinal;
> mpakQueueSize :cardinal;
> commandQueueSize :cardinal;
> end{MASC_SETTINGS};
>
> I'm not very familiar with c/c++ and pointers so I wouldn't be
> surprised if the explanation to the "access violation" lies in the
> conversion of different data types and pointers.
>
> Please help if you can, I'm stuck...
>
> Martin
> pointers from c/c++ to delphi.
I think that you are passing the record as an argument rather than a
pointer to the record that the dll function requires
try :-
function MASC_Open(hMASC :HMASC; address: PChar;
settings:PMASC_SETTINGS; Timeout: LongInt):integer; cdecl; external
MASCDLL;
type MASC_SETTINGS = record
frameQueueSize :cardinal;
mpakQueueSize :cardinal;
commandQueueSize :cardinal;
end;
type PMASC_SETTINGS = ^MASC_SETTINGS
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads