From: Mikko Rasa Date: Thu, 27 Dec 2007 17:10:20 +0000 (+0000) Subject: Store hInstance in Application class on win32 X-Git-Tag: 1.0~11 X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=commitdiff_plain;h=516755dde30a4820495580d1b52a5b992f800461 Store hInstance in Application class on win32 --- diff --git a/source/core/application.cpp b/source/core/application.cpp index c93475f..5acae82 100644 --- a/source/core/application.cpp +++ b/source/core/application.cpp @@ -24,7 +24,7 @@ application throws a UsageError, the static usage() function is called. This function can only be called once. The global main() function provided by the library normally does it automatically at program startup. */ -int Application::run(int argc, char **argv) +int Application::run(int argc, char **argv, void *data) { static bool called=false; if(called) @@ -40,6 +40,8 @@ int Application::run(int argc, char **argv) return 126; } + data_=data; + try { try @@ -201,5 +203,6 @@ Application::RegBase::RegBase() Application *Application::app_=0; Application::RegBase *Application::reg_app_=0; +void *Application::data_=0; } // namespace Msp diff --git a/source/core/application.h b/source/core/application.h index bd433aa..d3b992e 100644 --- a/source/core/application.h +++ b/source/core/application.h @@ -20,8 +20,9 @@ class Application public: virtual ~Application() { } - static int run(int, char **); + static int run(int, char **, void * =0); static void usage(const char *, const char *, bool); + static void *get_data() { return data_; } protected: enum LoopMode { @@ -70,6 +71,7 @@ private: static RegBase *reg_app_; static Application *app_; + static void *data_; static void sighandler_(int); static void sigalrm_(int) { } diff --git a/source/core/main.cpp b/source/core/main.cpp index 9fdaba2..5cf18c3 100644 --- a/source/core/main.cpp +++ b/source/core/main.cpp @@ -11,11 +11,11 @@ Distributed under the LGPL #include "application.h" #ifdef WIN32 -int APIENTRY WinMain(HINSTANCE /*hInstance*/, HINSTANCE /*hPrevInstance*/, LPSTR /*lpCmdLine*/, int /*nCmdShow*/) +int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPSTR /*lpCmdLine*/, int /*nCmdShow*/) { int argc = 0; LPWSTR *argv=CommandLineToArgvW(GetCommandLineW(), &argc); - return Msp::Application::run(argc, (char **)argv); + return Msp::Application::run(argc, (char **)argv, hInstance); } #endif