michael@0: // Unicode support by Jim Park -- 08/23/2007 michael@0: // Jim Park: Should probably turn this into a nice class for C++ programs. michael@0: michael@0: #pragma once michael@0: #include michael@0: #include michael@0: // only include this file from one place in your DLL. michael@0: // (it is all static, if you use it in two places it will fail) michael@0: michael@0: #define EXDLL_INIT() { \ michael@0: g_stringsize=string_size; \ michael@0: g_stacktop=stacktop; \ michael@0: g_variables=variables; } michael@0: michael@0: // For page showing plug-ins michael@0: #define WM_NOTIFY_OUTER_NEXT (WM_USER+0x8) michael@0: #define WM_NOTIFY_CUSTOM_READY (WM_USER+0xd) michael@0: michael@0: /* Jim Park: This char is compared as an int value and therefore michael@0: it's fine as an ASCII. Do not need to change to wchar_t since michael@0: it will get the same integer value. */ michael@0: #define NOTIFY_BYE_BYE _T('x') michael@0: michael@0: typedef struct _stack_t { michael@0: struct _stack_t *next; michael@0: TCHAR text[1]; // this should be the length of string_size michael@0: } stack_t; michael@0: michael@0: static unsigned int g_stringsize; michael@0: static stack_t **g_stacktop; michael@0: static TCHAR *g_variables; michael@0: michael@0: michael@0: enum michael@0: { michael@0: INST_0, // $0 michael@0: INST_1, // $1 michael@0: INST_2, // $2 michael@0: INST_3, // $3 michael@0: INST_4, // $4 michael@0: INST_5, // $5 michael@0: INST_6, // $6 michael@0: INST_7, // $7 michael@0: INST_8, // $8 michael@0: INST_9, // $9 michael@0: INST_R0, // $R0 michael@0: INST_R1, // $R1 michael@0: INST_R2, // $R2 michael@0: INST_R3, // $R3 michael@0: INST_R4, // $R4 michael@0: INST_R5, // $R5 michael@0: INST_R6, // $R6 michael@0: INST_R7, // $R7 michael@0: INST_R8, // $R8 michael@0: INST_R9, // $R9 michael@0: INST_CMDLINE, // $CMDLINE michael@0: INST_INSTDIR, // $INSTDIR michael@0: INST_OUTDIR, // $OUTDIR michael@0: INST_EXEDIR, // $EXEDIR michael@0: INST_LANG, // $LANGUAGE michael@0: __INST_LAST michael@0: }; michael@0: michael@0: typedef struct { michael@0: int autoclose; michael@0: int all_user_var; michael@0: int exec_error; michael@0: int abort; michael@0: int exec_reboot; michael@0: int reboot_called; michael@0: int XXX_cur_insttype; // deprecated michael@0: int XXX_insttype_changed; // deprecated michael@0: int silent; michael@0: int instdir_error; michael@0: int rtl; michael@0: int errlvl; michael@0: int alter_reg_view; michael@0: } exec_flags_type; michael@0: michael@0: typedef struct { michael@0: exec_flags_type *exec_flags; michael@0: int (__stdcall *ExecuteCodeSegment)(int, HWND); michael@0: void (__stdcall *validate_filename)(TCHAR *); michael@0: } extra_parameters; michael@0: michael@0: static int __stdcall popstring(TCHAR *str); // 0 on success, 1 on empty stack michael@0: static void __stdcall pushstring(const TCHAR *str); michael@0: static char * __stdcall getuservariable(const int varnum); michael@0: static void __stdcall setuservariable(const int varnum, const TCHAR *var); michael@0: michael@0: #ifdef _UNICODE michael@0: #define PopStringW(x) popstring(x) michael@0: #define PushStringW(x) pushstring(x) michael@0: #define SetUserVariableW(x,y) setuservariable(x,y) michael@0: michael@0: static int __stdcall PopStringA(char* ansiStr); michael@0: static void __stdcall PushStringA(const char* ansiStr); michael@0: static void __stdcall GetUserVariableW(const int varnum, wchar_t* wideStr); michael@0: static void __stdcall GetUserVariableA(const int varnum, char* ansiStr); michael@0: static void __stdcall SetUserVariableA(const int varnum, const char* ansiStr); michael@0: michael@0: #else michael@0: // ANSI defs michael@0: michael@0: #define PopStringA(x) popstring(x) michael@0: #define PushStringA(x) pushstring(x) michael@0: #define SetUserVariableA(x,y) setuservariable(x,y) michael@0: michael@0: static int __stdcall PopStringW(wchar_t* wideStr); michael@0: static void __stdcall PushStringW(wchar_t* wideStr); michael@0: static void __stdcall GetUserVariableW(const int varnum, wchar_t* wideStr); michael@0: static void __stdcall GetUserVariableA(const int varnum, char* ansiStr); michael@0: static void __stdcall SetUserVariableW(const int varnum, const wchar_t* wideStr); michael@0: michael@0: #endif michael@0: michael@0: static BOOL __stdcall IsUnicode(void) michael@0: static TCHAR* __stdcall AllocString(); michael@0: