Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.
App. not calling DLL function?
For some reason my c# app is not calling my c++ function in my dll. A little bit about what my app is suppose to do. My app has a global hook to detect WM_PASTE. When WM_PASTE is detect in the DLL it sets a flag back to the main app. If the flag is true, then paste is detected and the top data in the clipboard is extracted into a file. I have a messagebox at the beginning of my DLL. This is to show that it got into my DLL, but it doesn't reach there. I'm using VS 2008. I build my DLL and there were no errors. So I ran it and that's what happen.
public static extern bool registerHook();
The function below is in my c# app:
public void copyPaste()
//MessageBox.Show("Before calling register hook in paste dll."); // Debugging
bool pasteDetected = registerHook();
//MessageBox.Show("After calling register hook in paste dll."); // Debugging
IDataObject idata = Clipboard.GetDataObject();
String clipString = "";
if (pasteDetected && (idata != null)) /// Pasting
/// If the item is a text format then store in buffer and continue on.
if (idata.GetDataPresent(DataFormats.Text)) /// Text format.
clipString = (String)idata.GetData(DataFormats.Text);
keyBuffer += clipString;
The function below is my function in my DLL:
LRESULT CALLBACK MsgHookProc(int nCode, WPARAM wParam, LPARAM lParam);
_declspec(dllexport) bool registerHook()
MessageBox(NULL, "Inside registerHook() function.", "RegisterHook", NULL);
hHook = SetWindowsHookEx(WH_CALLWNDPROC, MsgHookProc, hHookDLL, 0);
LRESULT CALLBACK MsgHookProc(int nCode, WPARAM wParam, LPARAM lParam)
if(nCode >= 0)
PCWPSTRUCT pstInfo = (PCWPSTRUCT)lParam;
MessageBox(NULL, "Paste Detected
", Caption, NULL);
paste = true;
0 · ·