Results 1 to 11 of 11

Thread: DLL Path

  1. #1

    Thread Starter
    vbuggy krtxmrtz's Avatar
    Join Date
    May 2002
    Location
    In a probability cloud
    Posts
    5,573

    DLL Path

    I'd like to write:

    Private Declare Sub MySub Lib App.Path & "\Mydll.dll" (MyParam As ...)

    rather than

    Private Declare Sub MySub Lib "C:\VB\Projects\MyProj\Mydll.dll" (MyParam As ...)

    but unfortunately this is not allowed.

    Is there any way round or some trick to make the declaration path a relative one? I like to keep the dll in the app (and not in the Windows) directory because I'm often making changes and updates to it.
    Lottery is a tax on people who are bad at maths
    If only mosquitoes sucked fat instead of blood...
    To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: DLL Path

    If your dll is registered then it should not be necessary to declare the path as the default initial location windows looks for files is the applications path. Then in Windows. Then in System32. Basically a shortened enumeration of the locations windows looks.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3

    Thread Starter
    vbuggy krtxmrtz's Avatar
    Join Date
    May 2002
    Location
    In a probability cloud
    Posts
    5,573

    Re: DLL Path

    Quote Originally Posted by RobDog888
    If your dll is registered then it should not be necessary to declare the path as the default initial location windows looks for files is the applications path. Then in Windows. Then in System32. Basically a shortened enumeration of the locations windows looks.
    I tried to register it but I got this message:

    "...Mydll.dll was loaded but the DllRegisterServer entry point was not found"
    Lottery is a tax on people who are bad at maths
    If only mosquitoes sucked fat instead of blood...
    To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)

  4. #4
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: DLL Path

    Thats a different error then path not found. Did you use VB 6 to write the dll or is it a third party dll? Did you try it with the hard coded path and did it work?

    Try using Depends.exe to determine any dependancies that may not exist or ??? if its a third party dll.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  5. #5
    Shared Member
    Join Date
    May 2005
    Location
    Kashmir, India
    Posts
    2,277

    Re: DLL Path

    When you try it with the DLL in the application folder, do you recieve any error.
    VB Code:
    1. Private Declare Sub MySub Lib "C:\VB\Projects\MyProj\Mydll.dll" (MyParam As ...)
    If it is a Win32 Standard DLL then it does not need any registration.

    It should work even if the DLL is present in the same folder as your EXE.
    Use [code] source code here[/code] tags when you post source code.

    My Articles

  6. #6
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: DLL Path

    Yes, thats what I thought that it did look in the application path folder first but it sounds like the error mesage is dll dependant and not a Declare type issue.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  7. #7

    Thread Starter
    vbuggy krtxmrtz's Avatar
    Join Date
    May 2002
    Location
    In a probability cloud
    Posts
    5,573

    Re: DLL Path

    Quote Originally Posted by RobDog888
    [color=navy]Thats a different error then path not found. Did you use VB 6 to write the dll or is it a third party dll?
    I wrote it in c++
    Quote Originally Posted by RobDog888
    [color=navy]Did you try it with the hard coded path and did it work?]
    It did, yes.
    Lottery is a tax on people who are bad at maths
    If only mosquitoes sucked fat instead of blood...
    To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)

  8. #8
    old fart Frans C's Avatar
    Join Date
    Oct 1999
    Location
    the Netherlands
    Posts
    2,926

    Re: DLL Path

    I believe it is possible to declare it like:
    VB Code:
    1. Private Declare Sub MySub Lib "Mydll.dll" (MyParam As ...)

    VB should look in the application path as well.
    Frans

  9. #9

    Thread Starter
    vbuggy krtxmrtz's Avatar
    Join Date
    May 2002
    Location
    In a probability cloud
    Posts
    5,573

    Re: DLL Path

    Quote Originally Posted by Frans C
    VB should look in the application path as well.
    It doesn't work either. Btw I've tried in VB6 under Win98.
    Lottery is a tax on people who are bad at maths
    If only mosquitoes sucked fat instead of blood...
    To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)

  10. #10
    old fart Frans C's Avatar
    Join Date
    Oct 1999
    Location
    the Netherlands
    Posts
    2,926

    Re: DLL Path

    Did you try this in the IDE or with an exe?
    If you run the application from the IDE, windows regards the directory where VB6.exe is located as the application directory, and not the directory where your project is located.
    Frans

  11. #11

    Thread Starter
    vbuggy krtxmrtz's Avatar
    Join Date
    May 2002
    Location
    In a probability cloud
    Posts
    5,573

    Re: DLL Path

    Quote Originally Posted by Frans C
    Did you try this in the IDE or with an exe?
    If you run the application from the IDE, windows regards the directory where VB6.exe is located as the application directory, and not the directory where your project is located.
    You're right, it works after I've compiled it. But it's a nuisance having to cope with this from the IDE, as I'm still developing the project (and will be for quite long, probably) and I work on it from various computers having different pathes.
    Lottery is a tax on people who are bad at maths
    If only mosquitoes sucked fat instead of blood...
    To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width