Click here to Skip to main content
15,848,407 members
Home / Discussions / Managed C++/CLI
   

Managed C++/CLI

 
Questiondll into exe. Pin
bsaksida26-Dec-06 11:38
bsaksida26-Dec-06 11:38 
QuestionArray help. Pin
bsaksida26-Dec-06 2:29
bsaksida26-Dec-06 2:29 
AnswerRe: Array help. Pin
Dave Doknjas26-Dec-06 13:18
Dave Doknjas26-Dec-06 13:18 
GeneralRe: Array help. Pin
bsaksida26-Dec-06 22:57
bsaksida26-Dec-06 22:57 
QuestionExecute managed function from unmanaged Pin
yoti1126-Dec-06 1:02
yoti1126-Dec-06 1:02 
AnswerRe: Execute managed function from unmanaged Pin
567890123426-Dec-06 3:08
567890123426-Dec-06 3:08 
GeneralRe: Execute managed function from unmanaged Pin
yoti1126-Dec-06 4:08
yoti1126-Dec-06 4:08 
GeneralRe: Execute managed function from unmanaged Pin
567890123426-Dec-06 4:25
567890123426-Dec-06 4:25 
This is almost same case. The only difference that EnumWindows calls managed callback number of times inside of method, and keeping local delegate instance is enough. In your case you need to keep delegate as class member.
I think the problem is in function prototype. What is required unmanaged prototype and managed callback prototype?

In my program I use another method for managed callback - because I didn't know about this Marshal function when started to write it. Code fragments:

GCHandle gcHandle; // managed class member

// Constructor:
gcHandle = GCHandle::Alloc(this);
void* callbackPtr = GCHandle::ToIntPtr(gcHandle).ToPointer();
pUnmanagedClass->SetCallbackAddress(callbackPtr);

// Destructor:
gcHandle.Free();

Pass callbackPtr value to unmanaged class. This is simple unmanaged void* pointer, which allows to call managed class function when necessary.

// Unmanaged class calls managed class:
GCHandle h = GCHandle::FromIntPtr(IntPtr(callbackPtr)); // callbackPtr is passed from managed class
YourManagedClass^ pThis = (YourManagedClass^)h.Target;
pThis->CallbackFunction();

GeneralRe: Execute managed function from unmanaged Pin
yoti1126-Dec-06 7:21
yoti1126-Dec-06 7:21 
Questioncalling String ^ * from C# Pin
ByStorm Software25-Dec-06 18:09
ByStorm Software25-Dec-06 18:09 
AnswerRe: calling String ^ * from C# Pin
bsaksida26-Dec-06 20:47
bsaksida26-Dec-06 20:47 
GeneralRe: calling String ^ * from C# Pin
ByStorm Software27-Dec-06 5:27
ByStorm Software27-Dec-06 5:27 
GeneralRe: calling String ^ * from C# Pin
bsaksida27-Dec-06 5:35
bsaksida27-Dec-06 5:35 
GeneralRe: calling String ^ * from C# Pin
ByStorm Software27-Dec-06 5:42
ByStorm Software27-Dec-06 5:42 
GeneralRe: calling String ^ * from C# Pin
bsaksida27-Dec-06 6:40
bsaksida27-Dec-06 6:40 
GeneralRe: calling String ^ * from C# Pin
ByStorm Software27-Dec-06 7:12
ByStorm Software27-Dec-06 7:12 
GeneralRe: calling String ^ * from C# Pin
RockyMu1-Jul-22 16:01
RockyMu1-Jul-22 16:01 
Questionhandling system call result in C Pin
xface6625-Dec-06 9:08
xface6625-Dec-06 9:08 
AnswerRe: handling system call result in C Pin
xface6625-Dec-06 9:52
xface6625-Dec-06 9:52 
GeneralRe: handling system call result in C Pin
Christian Graus25-Dec-06 11:41
protectorChristian Graus25-Dec-06 11:41 
GeneralRe: handling system call result in C Pin
xface6625-Dec-06 13:36
xface6625-Dec-06 13:36 
GeneralRe: handling system call result in C Pin
John R. Shaw26-Dec-06 2:03
John R. Shaw26-Dec-06 2:03 
GeneralRe: handling system call result in C Pin
Christian Graus26-Dec-06 10:27
protectorChristian Graus26-Dec-06 10:27 
Questionmupad problem Pin
vasfar24-Dec-06 11:34
vasfar24-Dec-06 11:34 
AnswerRe: mupad problem Pin
Christian Graus25-Dec-06 11:40
protectorChristian Graus25-Dec-06 11: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.