🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.internet.web
5 messages
5 total messages Started by Fabi�n Thu, 08 Jul 2004 17:36
get dll path
#1795
Author: Fabi�n
Date: Thu, 08 Jul 2004 17:36
23 lines
1663 bytes
hi!

I' have a little problem.
I have made a isapi that returns wap pages.  Tis application reads a ini
file that is usually allocated in c:\winnt.
I have to add a new function to the application so it has to write in that
ini file,  but the usser of the internet information server don't have the
rights to write in that folder.  So I decided to put the ini file in the
same path of the dll, but I can't figure the way to get the path of the dll.
All I get is the path of  dllhost.exe.  (Application->ExeName)

I found an example in delphi, but i can't translate it to C++ Builder
because I don't know what is "hInstance"

var
  szFileName: array[0..MAX_PATH] of Char;
  DirStr : string;
begin
  GetModuleFileName(hInstance, szFileName, MAX_PATH);
  DirStr := ExtractFilePath(szFileName);


Ca you help me?
Re: get dll path
#1796
Author: Remy Lebeau (TeamB)
Date: Thu, 08 Jul 2004 18:15
16 lines
1243 bytes
"Fabi�n" <fabianfierro@hotmail.com> wrote in message
news:40ed8609$1@newsgroups.borland.com...

> I can't figure the way to get the path of the dll.

Call GetModuleFileName() using the HINSTANCE passed to the DLL's
DllEntryPoint() function.

> All I get is the path of  dllhost.exe.  (Application->ExeName)

You are not specifying the proper HINSTANCE when calling
GetModuleFileName().


Gambit
Re: get dll path
#1797
Author: Fabi�n
Date: Thu, 08 Jul 2004 18:25
54 lines
2340 bytes
That works....  but I don't know how to pass that information to the
Unit2.cpp

USEFORM("Unit2.cpp", PageProducerPage1); /* TWebAppPageModule: File Type */
char dllpath[1000];
//--------------------------------------------------------------------------
-
#define Application Webbroker::Application

#pragma link "isapiapp.obj"
#pragma link "isapithreadpool.obj"
#pragma link "webbroker.obj"
#pragma link "webinit.obj"
//--------------------------------------------------------------------------
-
int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void*)
{
  try
  {
    GetModuleFileName(hinst,dllpath,1000);

    if (reason == DLL_PROCESS_ATTACH) {
      CoInitFlags = COINIT_MULTITHREADED;
      Application->Initialize();
      Application->Run();
    }
  }
  catch (Exception &exception)
  {
  }
  return 1;
}


"Remy Lebeau (TeamB)" <gambit47.no.spam@no.spam.yahoo.com> escribi� en el
mensaje news:40ed8f41$1@newsgroups.borland.com...
>
> "Fabi�n" <fabianfierro@hotmail.com> wrote in message
> news:40ed8609$1@newsgroups.borland.com...
>
> > I can't figure the way to get the path of the dll.
>
> Call GetModuleFileName() using the HINSTANCE passed to the DLL's
> DllEntryPoint() function.
>
> > All I get is the path of  dllhost.exe.  (Application->ExeName)
>
> You are not specifying the proper HINSTANCE when calling
> GetModuleFileName().
>
>
> Gambit
>
>
Re: get dll path
#1799
Author: Remy Lebeau (TeamB)
Date: Thu, 08 Jul 2004 20:50
30 lines
1630 bytes
"Fabi�n" <fabianfierro@hotmail.com> wrote in message
news:40ed9170$1@newsgroups.borland.com...

> That works....  but I don't know how to pass
> that information to the Unit2.cpp

One way it to simply declare dllpath as 'extern' in Unit2, ie:

    --- MyDll.cpp ---

    char dllpath[MAX_PATH+1];

    int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void*)
    {
        if( reason == DLL_PROCESS_ATTACH ) {
            GetModuleFileName(hinst, dllpath, MAX_PATH);
            //...
        }
    }


    --- Unit2.cpp ---

    extern char dllpath[];

    // use dllpath as needed...


Gambit
Re: get dll path
#1806
Author: Fabi�n
Date: Mon, 12 Jul 2004 13:04
38 lines
1863 bytes
Thanks a lot !!!!

=)

"Remy Lebeau (TeamB)" <gambit47.no.spam@no.spam.yahoo.com> escribi� en el
mensaje news:40edb36b@newsgroups.borland.com...
>
> "Fabi�n" <fabianfierro@hotmail.com> wrote in message
> news:40ed9170$1@newsgroups.borland.com...
>
> > That works....  but I don't know how to pass
> > that information to the Unit2.cpp
>
> One way it to simply declare dllpath as 'extern' in Unit2, ie:
>
>     --- MyDll.cpp ---
>
>     char dllpath[MAX_PATH+1];
>
>     int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void*)
>     {
>         if( reason == DLL_PROCESS_ATTACH ) {
>             GetModuleFileName(hinst, dllpath, MAX_PATH);
>             //...
>         }
>     }
>
>
>     --- Unit2.cpp ---
>
>     extern char dllpath[];
>
>     // use dllpath as needed...
>
>
> Gambit
>
>
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads