|
hi All,
If i want to use LoadLibrary function to import a dll and i dont want to give static path and just give dll name so where i should put my dll in system 32 or somewhere else.....and should i register it or not...please tell me.
Thanks A Ton
Ash_VCPP
|
|
|
|
|
Like this:
HINSTANCE hInst;
hInst= LoadLibrary("SayItsMyLib");
You need to google first, if you have "It's urgent please" mentioned in your question.
_AnShUmAn_
|
|
|
|
|
i tried this way but its not working...where i should keep my dll any specific location like system32?
Thanks A Ton
Ash_VCPP
|
|
|
|
|
Did you register your dll? using the regsvr32 command
regsvr32 is used in for COM dll's
You need to google first, if you have "It's urgent please" mentioned in your question.
_AnShUmAn_
modified on Thursday, March 19, 2009 7:47 AM
|
|
|
|
|
yes i put my dll in system32 folder and then register it but still no hope....can u plz give some sample code or any header file which i am missing....
Thanks A Ton
Ash_VCPP
|
|
|
|
|
Can you check what does GetLastError() return value is?
You need to google first, if you have "It's urgent please" mentioned in your question.
_AnShUmAn_
|
|
|
|
|
_AnsHUMAN_ wrote: Did you register your dll? using the regsvr32 command
You only register COM DLLs. Normal, non-COM DLLs don't need to be registered.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
|
This[^] probably answers your question.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
i read the article but one question comes is:
i tried this way but its not working...where i should keep my dll any specific location like system32?
Thanks A Ton
Ash_VCPP
|
|
|
|
|
Will your DLL be used by other programs/processes or only by one application? If only by your own app, then i'd say, keep it next to your executable. Otherwise put it into the system directory, but avoid hardcoding paths, don't assume for example that the system directory is in c:\windows\system32, because what if the user installs his Os on -let's say- drive E, then the system folder should sit in e:\windows\system32.
You usually only need to register a DLL if it needs to do things like add registry entries or such before it can be used, so basicly, if your DLL needs registering or not depends on your DLL.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
Is it a system DLL? If it is, it really ought to live in a Windows system directory.
If it isn't, just put it in the same directory as your executable. The page that Code-o-mat pointed you at says that the first place the system looks for DLLs is "The directory from which the application loaded".
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
i tried by putting it at every possible place but its not working....is there any other way to import type library coz i imported it using static path??
Thanks A Ton
Ash_VCPP
|
|
|
|
|
If you put it in the same folder than your executable (and pass only the name of the DLL), this should work fine. If that's not the case, check the return value of GetLastError as somebody previously suggested. Maybe there's something wrong with your dll. Does it work if you supply the full path ?
|
|
|
|
|
yes while using import with full path it works fine but not sure why it is creating issue with loladlibrary?
Thanks A Ton
Ash_VCPP
|
|
|
|
|
So, for the 3rd time: what does GetLastError return ?
|
|
|
|
|
the code is giving compile time error because i have used dlls typelybrary classes so untill dll wont get imported it will give me errors so i wont be able to getlasterror....
Thanks A Ton
Ash_VCPP
|
|
|
|
|
No, I think you missed something really important here: you can't use classes from a dll if you are using LoadLibrary. This function (and the GetProcAddress) is only useful when you need to call functions from a dll.
If you need to use classes from your dll, you will need to use an import library.
Anhyway, this can't work even if you supply the path statically, because at compile time the compiler will never check if your dll is present or not (that doesn't make any sense).
|
|
|
|
|
the line which is giving me error is
MIBServer::_wboProxyCorePtr comProxyCore;
my dll name is MIBServer.dll
Thanks A Ton
Ash_VCPP
|
|
|
|
|
For the future, please read and try to understand the replies people give you. Look at the lenght of this discussion, it's crazy...
If you want to use classes from a dll, you need to use an import library. It's not possible via the LoadLibrary/GetProcAddress functions.
An import library is the .lib file that is generated with your dll.
|
|
|
|
|
Ash_VCPP wrote: the code is giving compile time error...
Which you have thus far failed to mention.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
I can't believe this had to be suggested a third time. He spent more time posting "It still doesn't work" than he would have calling that function.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
sorry but i didnt get you......what i got is i missed out something to mention..is it?
Thanks A Ton
Ash_VCPP
|
|
|
|
|
I think he's trying to get the longest programming discussion ever on CP
|
|
|
|
|
Hi Cedric,
Thanks alot for your valuable replies...and i really apologize for making the discussion so long......
can you suggest me some good book on COM???
Thanks A Ton
Ash_VCPP
|
|
|
|