-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTypesConversions4InnoSetup.iss
106 lines (95 loc) · 3.98 KB
/
TypesConversions4InnoSetup.iss
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
//***************************************************************************************************
// If my work helped you in any way please support me on:
// https://www.buymeacoffee.com/Wilenty
// or on:
// https://www.patreon.com/Wilenty
//
//***************************************************************************************************
#define test="TypesConversions4Test"
[Setup]
AppName={#test}
AppVersion=0.1
AppVerName={#test} by Wilenty
Uninstallable=no
PrivilegesRequired=lowest
CreateAppDir=False
OutputDir=.
OutputBaseFilename={#test}
#Include "TypesConversions4InnoSetup.isi"
[code]
Function MessageBoxA(hWnd: HWND; lpText: LPCSTR; lpCaption: LPCSTR; uType: UINT): Integer;
External 'MessageBoxA@User32.dll stdcall';
#if defined Unicode
Function MessageBoxW(hWnd: HWND; lpText: LPCWSTR; lpCaption: LPCWSTR; uType: UINT): Integer;
External 'MessageBoxW@User32.dll stdcall';
function GetCommandLineW: LPWSTR;
External 'GetCommandLineW@kernel32.dll stdcall';
#EndIf
//(*
Const
MB_ICONINFORMATION = $00000040;
//*)
Function InitializeSetup(): Boolean;
Var
PaString: PAnsiString;
aString: AnsiString;
#if defined Unicode
PwChar: PWideChar;
PwString: PWideString;
wString: WideString;
#EndIf
begin
aString := 'Wilenty''s Coversions Tests'#0;
MsgBox('Before conversions: ' + aString, mbInformation, MB_OK);
// Before first use, you must initiate the Pointer:
PaString := AnsiString2PAnsiString(aString);
// ^ Note, please don't call like this: AnsiString2PAnsiString(''); because you will see an error *
aString := PAnsiString2AnsiString(PaString);
With TMainForm.Create(nil) do
begin
MessageBoxA(Handle, 'Ansi result: ' + aString, 'MessageBoxA', MB_ICONINFORMATION);
Free;
end;
#if defined Unicode
// Before first use, you must initiate the Pointer:
PwChar := WideString2PWideChar( WideString(aString) );
// ^ Note, please don't call like this: WideString2PWideChar(''); because you will see an error *
wString := PWideChar2WideString(PwChar);
// Before first use, you must initiate the Pointer:
PwString := WideString2PWideString(wString);
// ^ Note, please don't call like this: WideString2PWideString(''); because you will see an error *
wString := PWideString2WideString(PwString);
With TMainForm.Create(nil) do
begin
MessageBoxW(Handle, WideString2PWideChar('Unicode result: ' + wString), WideString2PWideChar('MessageBoxW'), MB_ICONINFORMATION);
MessageBoxW(Handle, WideString2PWideChar( 'GetCommandLineW: ' + PWideChar2WideString( GetCommandLineW() ) ), WideString2PWideChar('MessageBoxW'), MB_ICONINFORMATION);
Free;
end;
Result := True;
#EndIf
end;
#if defined Unicode
function GetWindowTextLengthW(hWnd: HWND): Integer;
External 'GetWindowTextLengthW@User32.dll stdcall';
function GetWindowTextW(hWnd: HWND; lpString: LPWSTR; nMaxCount: Integer): Integer;
External 'GetWindowTextW@User32.dll stdcall';
#EndIf
Procedure InitializeWizard();
Var
PwChar: PWideChar;
begin
With WizardForm do
begin
// Before first use, you must initiate the Pointer:
PwChar := WideString2PWideChar(#0);
// ^ Note, please don't call like this: WideString2PWideChar(''); because you will see an error *
// and now you can use it...
SetLength4PWideChar( PwChar, GetWindowTextLengthW(Handle)+1 );
// ^ Note, please don't call like this: SetLength4PWideChar( PwChar, 0 ); because you will see an error *
// * please use the: PwChar := WideString2PWideChar(#0); instead, if you want to reset the content *
GetWindowTextW( Handle, PwChar, PWideChar4Length(PwChar) );
If Not CheckPWideChar4NIL(PwChar) then
MessageBoxW(Handle, WideString2PWideChar('GetWindowTextW: ' + PWideChar2WideString(PwChar)), WideString2PWideChar('MessageBoxW'), MB_ICONINFORMATION);
end;
Abort;
end;