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

Managed C++/CLI

 
AnswerRe: Hi all Pin
Mark Salsbery3-Feb-09 5:01
Mark Salsbery3-Feb-09 5:01 
QuestionHow to return array of custom objects from native C++ class to cpp/CLI class. Pin
Member 57039052-Feb-09 16:09
Member 57039052-Feb-09 16:09 
AnswerRe: How to return array of custom objects from native C++ class to cpp/CLI class. Pin
N a v a n e e t h2-Feb-09 18:20
N a v a n e e t h2-Feb-09 18:20 
GeneralRe: How to return array of custom objects from native C++ class to cpp/CLI class. Pin
Member 57039053-Feb-09 2:38
Member 57039053-Feb-09 2:38 
GeneralRe: How to return array of custom objects from native C++ class to cpp/CLI class. Pin
Mark Salsbery3-Feb-09 5:07
Mark Salsbery3-Feb-09 5:07 
Questionerror C2440: 'type cast' : cannot convert from 'System::String ^' to 'LPCTSTR' Pin
priyasethu1-Feb-09 19:57
priyasethu1-Feb-09 19:57 
AnswerRe: error C2440: 'type cast' : cannot convert from 'System::String ^' to 'LPCTSTR' Pin
Mark Salsbery2-Feb-09 8:05
Mark Salsbery2-Feb-09 8:05 
QuestionSetWindowsHookEx from Managed C++ Pin
Kar981-Feb-09 11:26
Kar981-Feb-09 11:26 
HI
I need hook events of keyboard in my app, this is made in managed c++, i did one dll in c++ for hook keyboard and this run good.

first i did simple app in C for test my dll and using SetWindowsHookEx
BOOL HazHook()
{

HOOKPROC hkprcSysMsg;
HPROC hkprcSysMsg2;
HINSTANCE hinstDLL;
HHOOK hhookSysMsg;

hinstDLL = LoadLibrary((LPCTSTR) "keyboard.dll");
if ( hinstDLL != NULL)
{
OutputDebugString ( "1> OK\n");

hkprcSysMsg2 = (HPROC)GetProcAddress(hinstDLL, "_keyboardHookProc@12");
if ( hkprcSysMsg2 != NULL)
{
OutputDebugString ( "2> OK\n");
// LocalhPrevInstance is hPrevInstance of WinMain app.
hhookSysMsg = SetWindowsHookEx(WH_KEYBOARD_LL,hkprcSysMsg2,hinstDLL,LocalhPrevInstance); // original

if( hhookSysMsg != NULL)
{
OutputDebugString ( "3> OK\n");
return TRUE;
}
else OutputDebugString ( "3> FAIL\n");

}else OutputDebugString ( "2> FAIL\n");
}else OutputDebugString ( "1> FAIL\n");
return FALSE;
}

The problems start whemn I need use SetWindowsHookEx in Managad C++, I try inport API but the conversion of rates I not know, HOOKPROC, HINSTANCE , DWORD is unsigned int

[DllImport("user32.dll")]
static int SetWindowsHookEx(int idHook, HOOKPROC lpfn, HINSTANCE hMod,DWORD dwThreadId);

Other try is using unamanged C++

#include "stdafx.h"
#pragma unmanaged

#include <windows.h>
#include <stdio.h>

typedef LRESULT (CALLBACK *HPROC)(int , WPARAM , LPARAM );

bool lalaLoadDllKeyboard()
{

HOOKPROC hkprcSysMsg;
HPROC hkprcSysMsg2;
HINSTANCE hinstDLL;
HHOOK hhookSysMsg;

hinstDLL = LoadLibrary( "keyboard.dll");
if ( hinstDLL != NULL)
{

hkprcSysMsg2 = (HPROC)GetProcAddress(hinstDLL, "_keyboardHookProc@12");
if ( hkprcSysMsg2 != NULL)
{
OutputDebugString ( "2> OK\n");

//hhookSysMsg = SetWindowsHookEx(WH_KEYBOARD_LL,hkprcSysMsg2,hinstDLL,LocalhPrevInstance); // original
hhookSysMsg = SetWindowsHookEx(WH_KEYBOARD_LL,hkprcSysMsg2,hinstDLL,0); // original
if( hhookSysMsg != NULL)
{
OutputDebugString ( "3> OK\n");
return true;
}
}
}
return false;

}

#pragma managed

But to compile errors:
1>------ Operación Generar iniciada: proyecto: WinFormsHookKeyboard, configuración: Debug Win32 ------
1>Vinculando...
1>codeunamanged.obj : error LNK2019: símbolo externo _SetWindowsHookExA@16 sin resolver al que se hace referencia en la función "bool __cdecl lalaLoadDllKeyboard(void)" (?lalaLoadDllKeyboard@@YA_NXZ)

Any idea ??

Thank
AnswerRe: SetWindowsHookEx from Managed C++ Pin
Mark Salsbery2-Feb-09 8:12
Mark Salsbery2-Feb-09 8:12 
Questionconvert row elements from two dimensional array to one dimensional arrays Pin
emira6730-Jan-09 23:39
emira6730-Jan-09 23:39 
QuestionCreate an image from a string in C++ .NET Pin
USAFHokie8029-Jan-09 11:19
USAFHokie8029-Jan-09 11:19 
AnswerRe: Create an image from a string in C++ .NET Pin
USAFHokie8029-Jan-09 11:43
USAFHokie8029-Jan-09 11:43 
AnswerRe: Create an image from a string in C++ .NET Pin
N a v a n e e t h29-Jan-09 15:11
N a v a n e e t h29-Jan-09 15:11 
Questionhow to send the settings from admin module to all user modules Pin
naveen_bij27-Jan-09 1:21
naveen_bij27-Jan-09 1:21 
QuestionSocket listening but not accepting, why? Pin
randomVariable26-Jan-09 20:46
randomVariable26-Jan-09 20:46 
QuestionRe: Socket listening but not accepting, why? Pin
led mike27-Jan-09 4:49
led mike27-Jan-09 4:49 
AnswerRe: Socket listening but not accepting, why? Pin
randomVariable27-Jan-09 6:07
randomVariable27-Jan-09 6:07 
GeneralRe: Socket listening but not accepting, why? Pin
staticv28-Jan-09 2:09
staticv28-Jan-09 2:09 
QuestionDoes anyone know how to use Mschart in Visual c++? Pin
sai5623-Jan-09 22:21
sai5623-Jan-09 22:21 
AnswerRe: Does anyone know how to use Mschart in Visual c++? Pin
N a v a n e e t h23-Jan-09 23:10
N a v a n e e t h23-Jan-09 23:10 
QuestionLinker Error in CLR library file while linking to native C++ application. Pin
Member 570390523-Jan-09 12:42
Member 570390523-Jan-09 12:42 
Questionthread creation Pin
staticv23-Jan-09 5:43
staticv23-Jan-09 5:43 
AnswerRe: thread creation Pin
teejayem23-Jan-09 7:46
teejayem23-Jan-09 7:46 
GeneralRe: thread creation Pin
staticv23-Jan-09 8:43
staticv23-Jan-09 8:43 
Questionhow to determine application path Pin
naveen_bij22-Jan-09 23:57
naveen_bij22-Jan-09 23:57 

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.