Click here to Skip to main content
15,881,757 members
Home / Discussions / C#
   

C#

 
QuestionHow to achieve automatic sorting in a TreeView? Pin
Morrgan29-Nov-05 4:45
Morrgan29-Nov-05 4:45 
AnswerRe: How to achieve automatic sorting in a TreeView? Pin
Curtis Schlak.29-Nov-05 9:08
Curtis Schlak.29-Nov-05 9:08 
GeneralRe: How to achieve automatic sorting in a TreeView? Pin
Morrgan29-Nov-05 20:14
Morrgan29-Nov-05 20:14 
GeneralRe: How to achieve automatic sorting in a TreeView? Pin
Curtis Schlak.30-Nov-05 1:59
Curtis Schlak.30-Nov-05 1:59 
QuestionComparing 2 strings and ignoring their case Pin
hasanali0029-Nov-05 3:22
hasanali0029-Nov-05 3:22 
AnswerRe: Comparing 2 strings and ignoring their case Pin
Guffa29-Nov-05 3:34
Guffa29-Nov-05 3:34 
QuestionHelp building a header !! Pin
Wicker_Basket29-Nov-05 3:04
Wicker_Basket29-Nov-05 3:04 
QuestionException while loading unmanaged Dll into C# Code Pin
Rashid.Mahmood29-Nov-05 2:18
Rashid.Mahmood29-Nov-05 2:18 
Hi all i have developed a dll in VC++7.0
and want to use it in C# code but i got exception:
" Unable to load DLL 'HookLib.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E) "

my Dll code is:

////////////////////////"HookLib.cpp"

#include "stdafx.h"

extern HINSTANCE g_appInstance;

BOOL APIENTRY DllMain(HINSTANCE hinstDLL, DWORD ul_reason_for_call, LPVOID lpReserved)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
//
// Capture the application instance of this module to pass to
// hook initialization.
//
if (g_appInstance == NULL)
{
g_appInstance = hinstDLL;
}
break;

case DLL_THREAD_ATTACH:
break;

case DLL_THREAD_DETACH:
break;

case DLL_PROCESS_DETACH:
break;

default:
//OutputDebugString("Not sure what just happened.\n");
break;
}

return TRUE;
}
/////////////////////

//////////////////////////"HookCore.h"
#pragma once

LRESULT CALLBACK GetMessageProc(int nCode, WPARAM wParam, LPARAM lParam);

bool InitializeHook();
void UninitializeHook();
////////////////


//////////////////////////"HookCore.cpp"
#include "stdafx.h"
#include <windows.h>
#include "HookCore.h"
#include "MessageFilter.h"

HHOOK hookMsg = NULL;
HINSTANCE g_appInstance = NULL;

LRESULT CALLBACK GetMessageProc(int nCode, WPARAM wParam, LPARAM lParam){
if (nCode == HC_ACTION) {
MSG *msg = (MSG *) lParam;
if(msg->message == WM_PAINT){
//Beep debug
Beep(1000,1);
//Write file debug
}
//Process message
//...
}
return CallNextHookEx (hookMsg, nCode, wParam, lParam);
}
bool InitializeHook()
{
if (g_appInstance == NULL)
{
return false;
}

hookMsg = SetWindowsHookEx(WH_CALLWNDPROC, (HOOKPROC)GetMessageProc,
g_appInstance, 0);

return hookMsg != NULL;
}

void UninitializeHook()
{
if(hookMsg != NULL)
{
UnhookWindowsHookEx(hookMsg);
}
hookMsg = NULL;

}
/////////////////////////////////////////////////

///////////////////////"HookCore.def"
LIBRARY "HookLib"

EXPORTS
InitializeHook
UninitializeHook
//////////////////////////////////////////////////////////////////////////

and my C# code to import dll functions is

DllImport("HookLib.dll", EntryPoint="InitializeHook", SetLastError=true,
CharSet=CharSet.Unicode, ExactSpelling=true,
CallingConvention=CallingConvention.StdCall)]
private static extern bool InitializeHook();

[DllImport("HookLib.dll", EntryPoint="UninitializeHook", SetLastError=true,
CharSet=CharSet.Unicode, ExactSpelling=true,
CallingConvention=CallingConvention.StdCall)]
private static extern void UninitializeHook();

then i use the InitializeHook() method i got the above exception
can somebody tell me how i can get rid of this

Thanx for ur response.
AnswerRe: Exception while loading unmanaged Dll into C# Code Pin
S. Senthil Kumar29-Nov-05 2:25
S. Senthil Kumar29-Nov-05 2:25 
GeneralRe: Exception while loading unmanaged Dll into C# Code Pin
Rashid.Mahmood29-Nov-05 3:45
Rashid.Mahmood29-Nov-05 3:45 
Questionbeginer 1 Pin
papa198029-Nov-05 2:06
papa198029-Nov-05 2:06 
AnswerRe: beginer 1 Pin
J4amieC29-Nov-05 2:58
J4amieC29-Nov-05 2:58 
GeneralRe: beginer 1 Pin
papa198029-Nov-05 4:49
papa198029-Nov-05 4:49 
GeneralRe: beginer 1 Pin
J4amieC29-Nov-05 4:56
J4amieC29-Nov-05 4:56 
GeneralRe: beginer 1 Pin
papa198029-Nov-05 5:48
papa198029-Nov-05 5:48 
GeneralRe: beginer 1 Pin
Dan Neely29-Nov-05 6:49
Dan Neely29-Nov-05 6:49 
GeneralRe: beginer 1 Pin
Guffa29-Nov-05 7:13
Guffa29-Nov-05 7:13 
GeneralRe: beginer 1 Pin
papa198029-Nov-05 19:37
papa198029-Nov-05 19:37 
GeneralRe: beginer 1 Pin
Dan Neely30-Nov-05 2:14
Dan Neely30-Nov-05 2:14 
GeneralRe: beginer 1 Pin
papa198030-Nov-05 5:02
papa198030-Nov-05 5:02 
GeneralRe: beginer 1 Pin
J4amieC30-Nov-05 6:54
J4amieC30-Nov-05 6:54 
QuestionSoftware protection Pin
mirano29-Nov-05 1:15
mirano29-Nov-05 1:15 
AnswerRe: Software protection Pin
Christian Graus29-Nov-05 17:20
protectorChristian Graus29-Nov-05 17:20 
QuestionHelp on Accessing enum Pin
rnvrnv29-Nov-05 0:14
rnvrnv29-Nov-05 0:14 
AnswerRe: Help on Accessing enum Pin
S. Senthil Kumar29-Nov-05 2:27
S. Senthil Kumar29-Nov-05 2:27 

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.