C
Christopher Sin
[repost, nobody have seen this message ?]
Hi,
First, if I am on a wrong group, please tell me,
therefore, i think this one is correct.
Second, please ignore my poor English speaking.
I have to write a c# wrapper to a C library.
This is OK, but I have difficulties with some functions
that deals with double indirections.
The C function is
ectern "C" {
UNIRESULT_S __declspec(dllexport) * __stdcall
uni_open_session (const char * args, UNISESSION_S * *
psession);
}
UNIRESULT_S and UNISESSION_S just are structures (but with
incomplete definition in headers).
This function allocate ressources and retruned this by the
psession pointer.
The returned value is a pointer on a structure.
I have tried this :
[DllImport("clirts32.dll", CharSet=CharSet.Ansi)]
public static extern IntPtr uni_open_session(String args,
ref IntPtr psession) ;
This works in some cases, but provoque an
NullPointerException in others.
(the case where it is works is console application
launcher, where with a web application aspnet, it is not).
The C function is part of a dll, given by a vendor.
He gave me also with .h include files, an vb6 example file.
This last file contains this :
Declare Function uni_open_session Lib "clirts32.dll"
(ByVal args As String, psession As Long) As Long
What is the equivalent in C# ?
How to use it ?
In my C# code, i use C function like this :
string args = "servername etc." ;
IntPtr m_session = new IntPtr(0) ;
IntPtr hresult = Clirts32.uni_open_session(args, ref
m_session) ;
The VB6 example code is
Dim session As Long ' Session-Handle
Dim result As Long
result = uni_open_session(arg_str, session)
Is someone have any idea ?
Is my code correct, and the probleme came from aspnet
references dlls ?
Or is my code incorrect ?
Thank you.
Hi,
First, if I am on a wrong group, please tell me,
therefore, i think this one is correct.
Second, please ignore my poor English speaking.
I have to write a c# wrapper to a C library.
This is OK, but I have difficulties with some functions
that deals with double indirections.
The C function is
ectern "C" {
UNIRESULT_S __declspec(dllexport) * __stdcall
uni_open_session (const char * args, UNISESSION_S * *
psession);
}
UNIRESULT_S and UNISESSION_S just are structures (but with
incomplete definition in headers).
This function allocate ressources and retruned this by the
psession pointer.
The returned value is a pointer on a structure.
I have tried this :
[DllImport("clirts32.dll", CharSet=CharSet.Ansi)]
public static extern IntPtr uni_open_session(String args,
ref IntPtr psession) ;
This works in some cases, but provoque an
NullPointerException in others.
(the case where it is works is console application
launcher, where with a web application aspnet, it is not).
The C function is part of a dll, given by a vendor.
He gave me also with .h include files, an vb6 example file.
This last file contains this :
Declare Function uni_open_session Lib "clirts32.dll"
(ByVal args As String, psession As Long) As Long
What is the equivalent in C# ?
How to use it ?
In my C# code, i use C function like this :
string args = "servername etc." ;
IntPtr m_session = new IntPtr(0) ;
IntPtr hresult = Clirts32.uni_open_session(args, ref
m_session) ;
The VB6 example code is
Dim session As Long ' Session-Handle
Dim result As Long
result = uni_open_session(arg_str, session)
Is someone have any idea ?
Is my code correct, and the probleme came from aspnet
references dlls ?
Or is my code incorrect ?
Thank you.