Click here to Skip to main content
15,886,017 members
Home / Discussions / ATL / WTL / STL
   

ATL / WTL / STL

 
QuestionHow to get used dll's path information programetically? Pin
litu kumar6-Nov-12 19:38
litu kumar6-Nov-12 19:38 
AnswerRe: How to get used dll's path information programetically? Pin
Richard MacCutchan6-Nov-12 21:40
mveRichard MacCutchan6-Nov-12 21:40 
GeneralRe: How to get used dll's path information programetically? Pin
litu kumar6-Nov-12 23:27
litu kumar6-Nov-12 23:27 
GeneralRe: How to get used dll's path information programetically? Pin
Richard MacCutchan7-Nov-12 4:54
mveRichard MacCutchan7-Nov-12 4:54 
GeneralRe: How to get used dll's path information programetically? Pin
litu kumar7-Nov-12 17:11
litu kumar7-Nov-12 17:11 
GeneralRe: How to get used dll's path information programetically? Pin
Richard MacCutchan7-Nov-12 21:34
mveRichard MacCutchan7-Nov-12 21:34 
GeneralRe: How to get used dll's path information programetically? Pin
litu kumar7-Nov-12 22:35
litu kumar7-Nov-12 22:35 
GeneralRe: How to get used dll's path information programetically? Pin
Richard MacCutchan8-Nov-12 0:16
mveRichard MacCutchan8-Nov-12 0:16 
litu kumar wrote:
why it was still printing the application's Exe path
I have already explained twice. If the DLL has not been loaded into your application's address space then the call to GetModuleHandle() will return NULL; something that you have not catered for in your code. If the module handle is NULL then GetModuleFileName() will return the path of your executable program. The sequence you should follow is:
C++
HMODULE hmod = LoadLibrary(TEXT("MyApp.dll"));
if (hmod != NULL)
{
    TCHAR szPath[MAX_PATH + 1];
    DWORD dwLen = GetModuleFileName(hmod, szPath, MAX_PATH);
    if (dwLen > 0)
    {
        wprintf(L"CURRENT DIRECTORY: %s\n" ,szPath);
    }
    else
    {
        // check GetLastError() for reason
    }
}
else
{
// display error message
}

One of these days I'm going to think of a really clever signature.

GeneralRe: How to get used dll's path information programetically? Pin
litu kumar8-Nov-12 2:58
litu kumar8-Nov-12 2:58 
GeneralRe: How to get used dll's path information programetically? Pin
Richard MacCutchan8-Nov-12 4:03
mveRichard MacCutchan8-Nov-12 4:03 
GeneralRe: How to get used dll's path information programetically? Pin
litu kumar15-Nov-12 19:53
litu kumar15-Nov-12 19:53 
GeneralRe: How to get used dll's path information programetically? Pin
Richard MacCutchan15-Nov-12 23:50
mveRichard MacCutchan15-Nov-12 23:50 
AnswerRe: How to get used dll's path information programetically? Pin
hacker240union22-Nov-12 23:41
hacker240union22-Nov-12 23:41 
Questiondetect close event with CAsyncSocket Pin
bkelly135-Nov-12 10:32
bkelly135-Nov-12 10:32 
QuestionIntermediate GUI Techniques Pin
bkelly132-Nov-12 3:21
bkelly132-Nov-12 3:21 
AnswerRe: Intermediate GUI Techniques Pin
Richard MacCutchan2-Nov-12 6:20
mveRichard MacCutchan2-Nov-12 6:20 
Questionproblem with sprintf_s() on win 7 Pin
Member 93537761-Nov-12 21:34
Member 93537761-Nov-12 21:34 
AnswerRe: problem with sprintf_s() on win 7 Pin
Richard MacCutchan1-Nov-12 22:50
mveRichard MacCutchan1-Nov-12 22:50 
GeneralRe: problem with sprintf_s() on win 7 Pin
bkelly132-Nov-12 3:16
bkelly132-Nov-12 3:16 
GeneralRe: problem with sprintf_s() on win 7 Pin
Richard MacCutchan2-Nov-12 6:15
mveRichard MacCutchan2-Nov-12 6:15 
GeneralRe: problem with sprintf_s() on win 7 Pin
Member 93537764-Nov-12 16:34
Member 93537764-Nov-12 16:34 
GeneralRe: problem with sprintf_s() on win 7 Pin
Richard MacCutchan4-Nov-12 21:26
mveRichard MacCutchan4-Nov-12 21:26 
AnswerRe: problem with sprintf_s() on win 7 Pin
H.Brydon26-Nov-12 19:36
professionalH.Brydon26-Nov-12 19:36 
Questionwsageterror() Pin
bkelly131-Nov-12 15:28
bkelly131-Nov-12 15:28 
AnswerRe: wsageterror() Pin
Richard MacCutchan1-Nov-12 22:48
mveRichard MacCutchan1-Nov-12 22:48 

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.