Click here to Skip to main content
15,908,674 members
Home / Discussions / C#
   

C#

 
GeneralRe: Hook on right button mouse Pin
teycir8-May-09 5:23
teycir8-May-09 5:23 
GeneralRe: Hook on right button mouse Pin
Member 10339078-May-09 7:39
Member 10339078-May-09 7:39 
AnswerRe: Hook on right button mouse Pin
teycir9-May-09 0:17
teycir9-May-09 0:17 
QuestionLane Detection Algorithm Pin
sebogawa7-May-09 6:08
sebogawa7-May-09 6:08 
AnswerRe: Lane Detection Algorithm Pin
Luc Pattyn7-May-09 6:21
sitebuilderLuc Pattyn7-May-09 6:21 
GeneralRe: Lane Detection Algorithm Pin
sebogawa7-May-09 6:26
sebogawa7-May-09 6:26 
GeneralRe: Lane Detection Algorithm Pin
Luc Pattyn7-May-09 6:48
sitebuilderLuc Pattyn7-May-09 6:48 
QuestionReturn int* to C# from C++ DLL? Pin
Alan Balkany7-May-09 5:35
Alan Balkany7-May-09 5:35 
Hi all,

I've wasted a day just trying to get a simple pointer back to C# from C++!

I have a C++ DLL returning an int* to a C# program. The problem is the int* in C# remains null after the assignment.

When I assign the C++ result to an IntPtr, I get a correct non-null value. However any attempt to assign this to an int* instantly results in null.

I've tried (from C#):

IntPtr intp = cppFunction ();	// Non-null.

int* pi = (int *) intp;            	// Results in null.

int* pi = (int *) intp.ToPointer ();	// Results in null.


void* vp = intp.ToPointer ();	// Non-null.
int* pi = (int *) vp; 		// Results in null.

I then gave up on simple assignment, and tried to get the value by reference:

C#:
[DllImport("vdrdll.dll", EntryPoint = @"?getLineContentsAsArg@@YAXAAPAH@Z")]
public unsafe static extern void getLineContentsAsArg (ref int* lca);

C++:
DLLEXPORT void getLineContentsAsArg (int*& lca)
{
    lca = calculateLineContents ();
}

A non-null pointer value is assigned in the DLL, but when it gets back to C#, it's null.

Can anyone tell me how to get an int* back to C#?
Thanks!
Alan
AnswerRe: Return int* to C# from C++ DLL? Pin
Luc Pattyn7-May-09 6:16
sitebuilderLuc Pattyn7-May-09 6:16 
GeneralRe: Return int* to C# from C++ DLL? Pin
Alan Balkany7-May-09 6:22
Alan Balkany7-May-09 6:22 
GeneralRe: Return int* to C# from C++ DLL? [modified] Pin
Luc Pattyn7-May-09 6:54
sitebuilderLuc Pattyn7-May-09 6:54 
GeneralRe: Return int* to C# from C++ DLL? [modified] Pin
Alan Balkany7-May-09 8:27
Alan Balkany7-May-09 8:27 
GeneralRe: Return int* to C# from C++ DLL? Pin
Luc Pattyn7-May-09 8:38
sitebuilderLuc Pattyn7-May-09 8:38 
GeneralRe: Return int* to C# from C++ DLL? Pin
Dan Neely7-May-09 9:29
Dan Neely7-May-09 9:29 
GeneralRe: Return int* to C# from C++ DLL? Pin
Luc Pattyn7-May-09 9:54
sitebuilderLuc Pattyn7-May-09 9:54 
QuestionProblem in Toolstrip Pin
priyamtheone7-May-09 5:24
priyamtheone7-May-09 5:24 
QuestionUpdating confirmation box by commandfield. Pin
magshine7-May-09 5:15
magshine7-May-09 5:15 
QuestionHow to put powerpoint on different displays (multiply monitors)? Pin
molda7-May-09 5:06
molda7-May-09 5:06 
AnswerRe: How to put powerpoint on different displays (multiply monitors)? Pin
OriginalGriff7-May-09 5:11
mveOriginalGriff7-May-09 5:11 
GeneralRe: How to put powerpoint on different displays (multiply monitors)? Pin
OriginalGriff7-May-09 5:46
mveOriginalGriff7-May-09 5:46 
GeneralRe: How to put powerpoint on different displays (multiply monitors)? Pin
molda7-May-09 6:17
molda7-May-09 6:17 
GeneralRe: How to put powerpoint on different displays (multiply monitors)? Pin
Luc Pattyn7-May-09 7:18
sitebuilderLuc Pattyn7-May-09 7:18 
GeneralRe: How to put powerpoint on different displays (multiply monitors)? Pin
OriginalGriff7-May-09 8:19
mveOriginalGriff7-May-09 8:19 
AnswerRe: How to put powerpoint on different displays (multiply monitors)? Pin
Luc Pattyn7-May-09 7:17
sitebuilderLuc Pattyn7-May-09 7:17 
GeneralRe: How to put powerpoint on different displays (multiply monitors)? Pin
molda7-May-09 21:40
molda7-May-09 21:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.