473,419 Members | 1,842 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,419 software developers and data experts.

call C function with double pointer

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.

Nov 15 '05 #1
0 1816

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Enquiries, Hopkins Research | last post by:
Hi all I have a conundrum that is puzzling me. I have a large codebase in C that I am converting to C++ as fast as possible (i.e. slowly because I keep learning new idioms and stumbling with...
11
by: Edd | last post by:
Hello all, I've made a data structure and an associated set of functions to enable me to store a dynamically-sized array of elements of whatever data type I like. Well that's the idea anyway......
9
by: shaun | last post by:
Dear all, I realized an error in a previous post, I reproduce it here because I'm still not sure how to solve it: I want to make a templated function which points to one-past-the-end of a...
7
by: bowlderster | last post by:
Hello,all. I want to get the array size in a function, and the array is an argument of the function. I try the following code. /*************************************** */ #include<stdio.h>...
12
by: Googy | last post by:
Hi!! Can any one explain me the meaning of following notations clearly : 1. typedef char(*(*frpapfrc()))(); frpapfrc f; 2. typedef int (*(arr2d_ptr)()); arr2d_ptr p; 3. typedef int...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.