From f7f202e6ec71c0f88d211d6a78f88ba017dee851 Mon Sep 17 00:00:00 2001 From: jean-pierre roux Date: Tue, 20 Apr 2010 12:19:46 +0000 Subject: [PATCH] Add GetDllAppPath(const char *nomdll); --- src/creaSystem.cxx | 16 ++++++++++++++++ src/creaSystem.h | 12 +++++------- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/src/creaSystem.cxx b/src/creaSystem.cxx index 69293a9..3205178 100644 --- a/src/creaSystem.cxx +++ b/src/creaSystem.cxx @@ -180,6 +180,22 @@ std::string System::GetDllAppPath(std::string &nomdll){ return path; } + +std::string System::GetDllAppPath(const char *nomdll){ + std::string path = "."; +#ifdef WIN32 + char currentPath[_MAX_PATH]; + HMODULE hand = GetModuleHandle(nomdll); + GetModuleFileName(hand, currentPath, _MAX_PATH); + + path = currentPath; + + path = path.substr(0,path.find_last_of("\\")); +#endif + return path; +} + + #if defined(_WIN32) #define CREACONTOUR_VALID_FILE_SEPARATOR_CHAR '\\' #else diff --git a/src/creaSystem.h b/src/creaSystem.h index 3e1142b..3a5b8d5 100644 --- a/src/creaSystem.h +++ b/src/creaSystem.h @@ -3,8 +3,8 @@ Program: crea Module: $RCSfile: creaSystem.h,v $ Language: C++ - Date: $Date: 2010/04/01 11:05:21 $ - Version: $Revision: 1.10 $ + Date: $Date: 2010/04/20 12:19:46 $ + Version: $Revision: 1.11 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -202,8 +202,6 @@ typedef unsigned int uint32_t; #define UINT32_MAX (4294967295U) #endif - - //----------------------------------------------------------------------------- @@ -216,10 +214,10 @@ namespace crea { /// returns true iff the program has a tty static int HasTTY(); - CREA_EXPORT static int GetAppPath(char *pname, size_t pathsize); - CREA_EXPORT static std::string GetDllAppPath(std::string &nomdll); + CREA_EXPORT static int GetAppPath(char *pname, size_t pathsize); + CREA_EXPORT static std::string GetDllAppPath(std::string &nomdll); + CREA_EXPORT static std::string GetDllAppPath(const char *nomdll); CREA_EXPORT static std::string GetExecutablePath(); - }; } // namespace crea -- 2.45.1