Click here to Skip to main content
       

ATL / WTL / STL

 
QuestionHow to get used dll's path information programetically? Pinmemberlitu kumar6-Nov-12 20:38 
AnswerRe: How to get used dll's path information programetically? PinmvpRichard MacCutchan6-Nov-12 22:40 
GeneralRe: How to get used dll's path information programetically? [modified] Pinmemberlitu kumar7-Nov-12 0:27 
GeneralRe: How to get used dll's path information programetically? PinmvpRichard MacCutchan7-Nov-12 5:54 
GeneralRe: How to get used dll's path information programetically? Pinmemberlitu kumar7-Nov-12 18:11 
GeneralRe: How to get used dll's path information programetically? PinmvpRichard MacCutchan7-Nov-12 22:34 
GeneralRe: How to get used dll's path information programetically? Pinmemberlitu kumar7-Nov-12 23:35 
GeneralRe: How to get used dll's path information programetically? PinmvpRichard MacCutchan8-Nov-12 1: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:
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? [modified] Pinmemberlitu kumar8-Nov-12 3:58 
GeneralRe: How to get used dll's path information programetically? PinmvpRichard MacCutchan8-Nov-12 5:03 
GeneralRe: How to get used dll's path information programetically? Pinmemberlitu kumar15-Nov-12 20:53 
GeneralRe: How to get used dll's path information programetically? PinmvpRichard MacCutchan16-Nov-12 0:50 
AnswerRe: How to get used dll's path information programetically? Pinmemberhacker240union23-Nov-12 0:41 
Questiondetect close event with CAsyncSocket [modified] Pinmemberbkelly135-Nov-12 11:32 
QuestionIntermediate GUI Techniques Pinmemberbkelly132-Nov-12 4:21 
AnswerRe: Intermediate GUI Techniques PinmvpRichard MacCutchan2-Nov-12 7:20 
Questionproblem with sprintf_s() on win 7 PinmemberMember 93537761-Nov-12 22:34 
AnswerRe: problem with sprintf_s() on win 7 PinmvpRichard MacCutchan1-Nov-12 23:50 
GeneralRe: problem with sprintf_s() on win 7 Pinmemberbkelly132-Nov-12 4:16 
GeneralRe: problem with sprintf_s() on win 7 PinmvpRichard MacCutchan2-Nov-12 7:15 
GeneralRe: problem with sprintf_s() on win 7 PinmemberMember 93537764-Nov-12 17:34 
GeneralRe: problem with sprintf_s() on win 7 PinmvpRichard MacCutchan4-Nov-12 22:26 
AnswerRe: problem with sprintf_s() on win 7 PinmemberH.Brydon26-Nov-12 20:36 
Questionwsageterror() Pinmemberbkelly131-Nov-12 16:28 
AnswerRe: wsageterror() PinmvpRichard MacCutchan1-Nov-12 23:48 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Advertise | Privacy | Mobile
Web04 | 2.8.141223.1 | Last Updated 22 Dec 2014
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid