News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Dynamic Linking

Started by Twister, July 07, 2010, 07:28:05 AM

Previous topic - Next topic

Twister

Would I be able to link an application to a dynamic-linked library then place that library in a different folder (/bin) and with the application in the parent folder? (I don't want the library in the same folder as the application.)

hutch--

Your application must be able to find the DLL. Either in the same directory as the caller, in a directory in the system PATH or at a specific location that the calling application knows.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

Twister

Hutch,

I am planning on using an application manifest to give Windows a path to load my libraries (/bin). (Applcation Manifests (Windows); http://msdn.microsoft.com/en-us/library/aa374191%28v=VS.85%29.aspx)

dedndave

you could put the DLL in system32 and register it, as well

Twister

Quote from: dedndave on July 07, 2010, 08:25:44 AM
you could put the DLL in system32 and register it, as well

Is that legal?  :eek

dedndave

of course
many programs you have installed on your computer have done it
it's an especially good plan if you think the same library may be used by another program
of course, there may be version issues, that's what sxs is all about

Twister

It looks like a clutter, and makes hell for the simple user.

Oh, I don't think other applications would use it. Grouping the binaries together may be best for my case. Plus, it would be easy access for the user if they want to work off it.

dedndave

here is a reg file i use...
REGEDIT4

[HKEY_CLASSES_ROOT\.dll]
@="dllfile"

[HKEY_CLASSES_ROOT\dllfile\shell\regdll]
@="Register ActiveX DLL"

[HKEY_CLASSES_ROOT\dllfile\shell\regdll\command]
@="regsvr32.exe \"%L\""

[HKEY_CLASSES_ROOT\dllfile\shell\unregdll]
@="Unregister ActiveX DLL"

[HKEY_CLASSES_ROOT\dllfile\shell\unregdll\command]
@="regsvr32.exe /u \"%L\""

[HKEY_CLASSES_ROOT\.ocx]
@="ocxfile"

[HKEY_CLASSES_ROOT\ocxfile\shell\regocx]
@="Register OCX Control"

[HKEY_CLASSES_ROOT\ocxfile\shell\regocx\command]
@="regsvr32.exe \"%L\""

[HKEY_CLASSES_ROOT\ocxfile\shell\unregocx]
@="Unregister OCX Control"

[HKEY_CLASSES_ROOT\ocxfile\shell\unregocx\command]
@="regsvr32.exe /u \"%L\""

that will allow you to right-click on dll and ocx files to register or unregister them

Twister

That's not quite what I was going for.  :P

dedndave

well - it shows you how to use REGSVR32 to register a DLL
REGSVR32 /? will also get you there

sinsi

I think all your problems stem from having your dll in the bin directory.
Using LoadLibrary would be OK with a relative path, but not if the dll shows up in your imports.
Why the restriction of having to be in bin?

dave, you need to export the two procedures for regsvr32 to work. There are even a few windows components that don't (e.g. zip folders in win7 grrr.)
Light travels faster than sound, that's why some people seem bright until you hear them.

Twister

Sinsi,

What happens with storing libraries in the safe, comfy bin folder?

Rockoon

What happened to also putting the executable in the bin folder so that there wouldnt be a problem? :)
When C++ compilers can be coerced to emit rcl and rcr, I *might* consider using one.

Twister

That's an old method; it needs to be more modern. Out with the old standards, in with the new.  :clap:

jj2007

LoadLibray: When no path is specified, the function searches...

In other words (repeating what Hutch wrote already):
Use invoke LoadLibrary, chr$("mystuff") to let Windows crawl the usual places until it finds the dll
Use invoke LoadLibrary, chr$("bin\mystuff.dll") to get exactly that version.