Article View: borland.public.cppbuilder.nativeapi
Article #9028Re: Odd LoadLibrary Failure
From: Michael Lueck
Date: Tue, 17 Aug 2004 23:48
Date: Tue, 17 Aug 2004 23:48
55 lines
2548 bytes
2548 bytes
Remy Lebeau (TeamB) wrote:
> Actually, you should use this:
>
> HMODULE Dll = GetModuleHandle("SHELL32");
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/getmodulehandle.asp
Says you can put on the .DLL or not, if it is not there it adds it for you.
Still errors without the .DLL
#include <iostream.h>
#include <windows.h>
int main(void)
{
HMODULE Dll = GetModuleHandle("SHELL32");
if (Dll == NULL)
{
TCHAR szBuf[80];
LPVOID lpMsgBuf;
DWORD dw = GetLastError();
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM,
NULL,
dw,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR) &lpMsgBuf,
0, NULL );
wsprintf(szBuf,
"%s failed with error %d: %s",
"GetModuleHandle", dw, lpMsgBuf);
cout << szBuf;
LocalFree(lpMsgBuf);
}
cout << "Dll=" << Dll << "\n";
return 0;
};
GetModuleHandle failed with error 126: The specified module could not be found.
Dll=00000000
--
Michael Lueck
Lueck Data Systems
Remove the upper case letters NOSPAM to contact me directly.
Technical Details
Message-ID:
<41229902$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!gatel-ffm!gatel-ffm!194.25.134.126.MISMATCH!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<41228167$1@newsgroups.borland.com> <412289f4$1@newsgroups.borland.com> <41228d3b$1@newsgroups.borland.com> <4122950f$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,8d61921d2e5eb0c4 X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit Date: Tue, 17 Aug 2004 19:48:01 -0400 From: Michael Lueck <NmlueckO@SlueckPdataAsystemsM.com> Reply-To: NmlueckO@SlueckPdataAsystemsM.com Organization: Lueck Data Systems User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.1) Gecko/20040707 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: borland.public.cppbuilder.nativeapi Subject: Re: Odd LoadLibrary Failure References: <41228167$1@newsgroups.borland.com> <412289f4$1@newsgroups.borland.com> <41228d3b$1@newsgroups.borland.com> <4122950f$1@newsgroups.borland.com> In-Reply-To: <4122950f$1@newsgroups.borland.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 24.247.116.250 Message-ID: <41229902$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1092786434 24.247.116.250 (17 Aug 2004 16:47:14 -0700) Lines: 55 Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!gatel-ffm!gatel-ffm!194.25.134.126.MISMATCH!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail