Click here to Skip to main content
16,005,682 members
Home / Discussions / Managed C++/CLI
   

Managed C++/CLI

 
GeneralVisual C++ Different Icons for Release and Debug Pin
14-Jul-05 22:17
suss14-Jul-05 22:17 
GeneralRe: Visual C++ Different Icons for Release and Debug Pin
Neelesh K J Jain16-Jul-05 8:59
Neelesh K J Jain16-Jul-05 8:59 
GeneralRe: Visual C++ Different Icons for Release and Debug Pin
20-Jul-05 17:20
suss20-Jul-05 17:20 
GeneralRe: Visual C++ Different Icons for Release and Debug Pin
Neelesh K J Jain20-Jul-05 19:31
Neelesh K J Jain20-Jul-05 19:31 
Generalgcroot constructor crash Pin
Xen3h14-Jul-05 9:51
Xen3h14-Jul-05 9:51 
General.net dialog boxes Pin
istrasci14-Jul-05 7:45
istrasci14-Jul-05 7:45 
GeneralRe: .net dialog boxes Pin
Christian Graus14-Jul-05 11:15
protectorChristian Graus14-Jul-05 11:15 
QuestionHow to prevent a delegate from relocating on the CLR heap Pin
Florian Albrechtskirchinger13-Jul-05 7:41
Florian Albrechtskirchinger13-Jul-05 7:41 
Hi everyone!

I’m trying to write a global hook in C# and C++\CLI. I’m almost done if there wasn’t this little delegate problem.
I get the function pointer to a delegate and pass it to my hook.dll. The delegate gets called for a few seconds but then the delegate seems to be relocated on the CLR heap.
If tried using a GCHandle but as far as I can tell this only prevents the garbage collector from collecting my delegate and doesn’t stop relocation.
Then there is pin_ptr. But a pinning pointer only works till it goes out of scope and it can only be declared locally so this happens immediately after I get the function pointer. By the way, I use ...

proc = (HOOKPROC)(Marshal::GetFunctionPointerForDelegate(innerEventHandler).ToPointer());

... to get the function pointer.
If anyone knows how to pin the delegate for as long as I need to point to it from unmanaged code or has any ideas, workarounds, etc. please let me know!
Thank you very much in advance!

Regards,
Florian
AnswerRe: How to prevent a delegate from relocating on the CLR heap Pin
Sheng Jiang 蒋晟15-Jul-05 18:17
Sheng Jiang 蒋晟15-Jul-05 18:17 
GeneralRe: How to prevent a delegate from relocating on the CLR heap Pin
Florian Albrechtskirchinger16-Jul-05 5:14
Florian Albrechtskirchinger16-Jul-05 5:14 
GeneralRe: How to prevent a delegate from relocating on the CLR heap Pin
Sheng Jiang 蒋晟16-Jul-05 5:54
Sheng Jiang 蒋晟16-Jul-05 5:54 
GeneralRe: How to prevent a delegate from relocating on the CLR heap Pin
Florian Albrechtskirchinger16-Jul-05 8:01
Florian Albrechtskirchinger16-Jul-05 8:01 
GeneralRe: How to prevent a delegate from relocating on the CLR heap Pin
Florian Albrechtskirchinger16-Jul-05 22:51
Florian Albrechtskirchinger16-Jul-05 22:51 
GeneralMultible Instances. Pin
Saksida Bojan13-Jul-05 4:11
Saksida Bojan13-Jul-05 4:11 
GeneralRe: Multible Instances. Pin
toxcct13-Jul-05 5:57
toxcct13-Jul-05 5:57 
GeneralRe: Multible Instances. Pin
Tom Archer13-Jul-05 10:14
Tom Archer13-Jul-05 10:14 
GeneralDetect if .NET Framework is installed Pin
Saksida Bojan13-Jul-05 4:09
Saksida Bojan13-Jul-05 4:09 
GeneralRe: Detect if .NET Framework is installed Pin
Christian Graus13-Jul-05 12:37
protectorChristian Graus13-Jul-05 12:37 
GeneralRe: Detect if .NET Framework is installed Pin
Saksida Bojan14-Jul-05 0:14
Saksida Bojan14-Jul-05 0:14 
GeneralRe: Detect if .NET Framework is installed Pin
Christian Graus14-Jul-05 11:07
protectorChristian Graus14-Jul-05 11:07 
GeneralRe: Detect if .NET Framework is installed Pin
Saksida Bojan14-Jul-05 19:10
Saksida Bojan14-Jul-05 19:10 
GeneralRe: Detect if .NET Framework is installed Pin
Nish Nishant18-Jul-05 1:19
sitebuilderNish Nishant18-Jul-05 1:19 
GeneralSetting Global environment variable Pin
e_prabhu12-Jul-05 4:53
e_prabhu12-Jul-05 4:53 
GeneralFile Operation Monitoring Pin
e_prabhu12-Jul-05 3:45
e_prabhu12-Jul-05 3:45 
GeneralSwitch Error Pin
Saksida Bojan11-Jul-05 22:06
Saksida Bojan11-Jul-05 22:06 

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.