|
View:
New views
7 Messages
—
Rating Filter:
Alert me
|
|
|
|
|
|
Re: Plug-in calling a dll on the same folderTry this:
GetModuleFileName (GetModuleHandle(L"MyDll.dll"), (LPWSTR)path, 256);
|
|
|
RE: Plug-in calling a dll on the same folderHere’s my function: From: 4D-Plugins@... [mailto:4D-Plugins@...] On Behalf Of Laurent LUGANS Hello, |
|
|
RE: Plug-in calling a dll on the same folderHere’s my function: char*
ReadDLLPath(void){ char moduleDrive[4] = ""; char modulePath[512] = ""; GetModuleFileName(_hinstDLL, _dllPath, sizeof(_dllPath)); _splitpath( _dllPath, moduleDrive, modulePath, NULL,
NULL ); _makepath( _dllPath, moduleDrive, modulePath, "NameOfYourDLLWithoutTheExtension", "dll" ); return &_dllPath[0]; } From: 4D-Plugins@... [mailto:4D-Plugins@...] On Behalf Of Laurent LUGANS Hello, |
|
|
RE: Plug-in calling a dll on the same folderI forgot to
tell you, _dllPath is a module variable declared this way: char _dllPath[2048] = ""; From: 4D-Plugins@... [mailto:4D-Plugins@...] On Behalf Of Simon Besner Here’s my function: char*
ReadDLLPath(void){ char
moduleDrive[4] = ""; char
modulePath[512] = ""; GetModuleFileName(_hinstDLL,
_dllPath, sizeof(_dllPath)); _splitpath( _dllPath,
moduleDrive, modulePath, NULL, NULL ); _makepath( _dllPath,
moduleDrive, modulePath, "NameOfYourDLLWithoutTheExtension", "dll" ); return
&_dllPath[0]; } From: 4D-Plugins@... [mailto:4D-Plugins@...] On Behalf Of Laurent LUGANS Hello, |
|
|
|
|
|
Re: Plug-in calling a dll on the same folderLaurent
On 25/06/2009, at 11:08 PM, Laurent LUGANS wrote: > This function return the path of 4D application. > > On the client, the dll is in the folder with the plug-in, for > example : > C:\Documents and Settings\user\Application Data\4D\Appli. > 4DB_192_168_1_210\WIN4DX\ > > In the archives, i found this email : > >> > Does anybody have a better solution that will allow me to retrieve >> > the Extras folder path directly in the Plugin? >> Yes, have a look at this post: >> >> http://www.4d.com/4DLINK2/4DACTION/Web_Solutions/Show.WebSTARList? >> tCaseID=97807 >> >> The code example shows how to get the path to your plugin on Windows >> and load a DLL from this directory. It also explains delay loading so >> you can statically link to your DLL. This way you don't have to use >> GetProcAddress for each function. >> >> HTH, >> >> - Rob Laveaux >> > but the link doesn't work. Here is the code I use, which I think is probably based on the posting from the link above... I can't remember who should get credit for it - Rob? Danis? Thibaud? or perhaps all three! __declspec(dllexport) BOOL WINAPI DllMain( HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved ); char gPluginPath[_MAX_PATH] = ""; //Full path to the plugin Windows folder BOOL WINAPI DllMain( HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved ) { if ( fdwReason == DLL_PROCESS_ATTACH ) { char *pos = NULL; GetModuleFileName( hinstDLL, gPluginPath, sizeof( gPluginPath ) ); pos = strrchr( gPluginPath, '\\' ); gPluginPath[ pos-gPluginPath+1 ] = '\0'; } return TRUE; } BOOL LoadDLL ( char* dllName, HINSTANCE* library ) { char fullPath[_MAX_PATH]; fullPath[0] = 0; (void *)strcpy( fullPath, gPluginPath ); (void *)strcat( fullPath, dllName ); (void *)strcat( fullPath, ".dll"); *library = LoadLibraryEx( fullPath, NULL, LOAD_WITH_ALTERED_SEARCH_PATH ); if ( *library == NULL ) { LPTSTR errorText; FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, (DWORD)GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&errorText, 0, NULL ); PA_Alert( (char *)errorText ); LocalFree( errorText ); } return ( *library != NULL ); } Then in your code you can do something like: HINSTANCE myLibrary; if ( LoadDLL( "mydll", &myLibrary ) == TRUE ) { // Do some stuff here } Regards Justin Carr ********************************************************************** 4D Plugins hosted by 4D, Inc. http://www.4D.com/ Register for 4D Summit 2009 Today Early Bird Pricing Ends August 28th - http://www.4D.com/summit To Unsubscribe: mailto:4D-Plugins-off@... *********************************************************************** |
| Free embeddable forum powered by Nabble | Forum Help |