|
|
|
#1
|
||||
|
||||
|
does anyone know how to convert this following Delphi code into InnoSetup?
alternatively, if you have any other suggestions on how to accomplish this in a similar manner, please feel free to share your thoughts. thanks. Code:
uses
Winapi.Windows, System.SysUtils;
type
TFuncX = procedure(const Var1: Integer); cdecl;
TFuncY = function(const Count: Longint; var Str: AnsiString): Integer; cdecl;
TFuncZ = procedure(const Str1, Str2: WideString); cdecl;
TFuncCommon = record
case Integer of
0: (FuncX: TFuncX);
1: (FuncY: TFuncY);
2: (FuncZ: TFuncZ);
end;
function MySafeLoadLibFunc(const LibName, FuncName: WideString;
var Func: TFuncCommon; var ErrorStr: WideString): Cardinal;
begin
ErrorStr := '';
Result := LoadLibraryW(PWideChar(LibName));
if Result > 32 then begin
try
case Integer(Func) of // Get the address of the function by name
0: Func.FuncX := GetProcAddress(Result, PWideChar(FuncName));
1: Func.FuncY := GetProcAddress(Result, PWideChar(FuncName));
2: Func.FuncZ := GetProcAddress(Result, PWideChar(FuncName));
end;
if not Assigned(Pointer(Integer(Func))) then begin
ErrorStr := 'Could not find function "' + FuncName + '" in library "' + LibName + '"';
Result := 0;
end;
except
on E: Exception do begin
ErrorStr := 'Error loading function "' + FuncName + '" from library "' + LibName + '": ' + E.Message;
Result := 0;
end;
end;
end else ErrorStr := 'Could not load library "' + LibName + '"';
if ErrorStr = '' then ErrorStr := 'empty';
end;
Code:
USAGE:
procedure Test;
var
MyFunc: TFuncCommon;
ErrorStr: WideString;
LibModule: Cardinal;
TmpStr: AnsiString;
begin
try
LibModule := MySafeLoadLibFunc('MyDll.dll', 'MyFunc3', MyFunc, ErrorStr);
if LibModule > 32 then
begin
//MyFunc.FuncX(69); // Call function FuncX
//MyFunc.FuncY(47, TmpStr); // Call function FuncY
MyFunc.FuncZ('Hello', 'World'); // Call function FuncZ
FreeLibrary(LibModule); // Free MyDll.dll
end
else WriteLn(ErrorStr);
except
on E: Exception do WriteLn(E.ClassName, ': ', E.Message);
end;
end;
Code:
MyDll:
library MyDll;
uses
System.SysUtils, Winapi.Windows;
{$R *.res}
function ShowMsg(const Msg: WideString; Caption: WideString = 'A Msg From MyDll.dll'): Integer; cdecl;
begin
Result := MessageBoxW(0, PWideChar(Msg), PWideChar(Caption), MB_OK);
end;
procedure MyFunc1(const Var1: Integer); cdecl;
begin
ShowMsg('[MyFunc1] : Var1 = ' + IntToStr(Var1));
end;
function MyFunc2(const Count: Longint; var Str: AnsiString): Integer; cdecl;
begin
Str := 'BLACKFIRE';
Result := -10;
ShowMsg('[MyFunc2] : Count = ' + IntToStr(Count));
end;
procedure MyFunc3(const Str1, Str2: WideString); cdecl;
begin
ShowMsg('[MyFunc3] : Str1 = ' + Str1 + ', Str2 = ' + Str2);
end;
exports MyFunc1, MyFunc2, MyFunc3;
begin
end.
|
| Sponsored Links |
|
#2
|
||||
|
||||
|
Quote:
|
|
#3
|
|||
|
|||
|
ChatGPT is notoriously bad at writing complicated code. Sure, it can write simple algorithms, I use it sometimes to write quick scripts for making my repacks, but anything beyond this it usually gets the syntax wrong or the program will not work.
|
|
#4
|
||||
|
||||
|
Code:
#define public RequiredSpace "1000"
#define MbToBytes(str *Value) \
Local[1] = MbToBytes((Value)), \
Local[1]
[Setup]
AppName=111
AppVersion=0.0
AppPublisher=bbbbb
DefaultDirName={autopf}\111
ExtraDiskSpaceRequired={#MbToBytes(RequiredSpace)}
[_Code]
function MbToBytes(Value: Integer): Integer;
begin
Result := (Value * (1024 * 1024));
end;
__________________
¤ Life good be a Dream ¤ Last edited by Lord.Freddy; 10-04-2023 at 07:55. |
|
#5
|
||||
|
||||
|
You cannot mix ISPP and CODE section codes.
Try like this: Code:
#define public RequiredSpace "1000"
#define MbToBytes(str Value) \
Int(Value, 0) * 1024 * 1024
[Setup]
AppName=111
AppVersion=0.0
AppPublisher=bbbbb
DefaultDirName={autopf}\111
ExtraDiskSpaceRequired={#MbToBytes(RequiredSpace)}
|
| The Following User Says Thank You to Cesar82 For This Useful Post: | ||
Lord.Freddy (10-04-2023) | ||
|
#6
|
||||
|
||||
|
Code:
function CreateFileMapping( File: Cardinal; Attributes: Cardinal; Protect: Cardinal; MaximumSizeHigh: Cardinal; MaximumSizeLow: Cardinal; Name: PAnsiChar): Cardinal; external '[email protected] stdcall'; function MapViewOfFile( FileMappingObject: THandle; DesiredAccess: Cardinal; FileOffsetHigh: Cardinal; FileOffsetLow: Cardinal; NumberOfBytesToMap: Cardinal): PChar; external '[email protected] stdcall'; File mapping is a technique that allows you to map the contents of a file into the virtual memory space of a process. This allows you to access the contents of the file as if it were in memory, rather than on disk. There are several benefits to using file mapping: • Performance: File mapping can improve the performance of file I/O operations by reducing the number of disk accesses. When you map a file into memory, the operating system can use its virtual memory management mechanisms to cache the contents of the file in memory. This means that subsequent accesses to the file can be satisfied from memory, rather than requiring a disk access. • Concurrency: File mapping allows multiple processes to access the same file concurrently. When multiple processes map the same file into their virtual memory space, they can all access the contents of the file simultaneously. This can be useful for inter-process communication and data sharing. • Ease of use: File mapping allows you to access the contents of a file using memory-mapped I/O operations, rather than traditional file I/O operations. This can make it easier to work with files, as you can use pointer arithmetic and other memory-based operations to manipulate the contents of the file. Overall, file mapping is a powerful technique that can improve the performance and ease-of-use of file I/O operations. It is widely used in many different types of applications and is supported by most modern operating systems. Last edited by Junior53; 07-06-2023 at 17:37. Reason: I found the answer myself :) |
|
#7
|
|||
|
|||
|
error everytime
Hi
In last days I used method (xt_zlib+srep_new:3+LOLZ_NORMAL) DiskSpan In thes games Call of Duty Ghosts Call of Duty Black Ops 4 A Plague Tale Requiem but every time after click on install this what come to me what is the wrong that I did? |
|
#8
|
||||
|
||||
|
Quote:
Make sure the selected installation path is not too long. Try installing in a folder like "D:\Games\Call of Duty Ghosts" It also cannot contain special characters in the installation path. |
| The Following User Says Thank You to Cesar82 For This Useful Post: | ||
IRAQIGHOST (10-05-2023) | ||
|
#9
|
||||
|
||||
|
My question is not about INNO but batch. Since batch is not something I deal everyday with, I need some help here. I don't want to open a new topic for this.
I have some files which I extract with a tool. The problem is that the extracted folders have the exact name as the files. For example Code:
File1.abc > Folder1.abc File2.abc > Folder2.abc ... I already tried something like this but didn't work. Code:
for /d %%i in (*.abc) do ren "%%~i" *
__________________
Haters gonna hate
|
|
#10
|
||||
|
||||
|
Quote:
Code:
for /d %%i in (*.abc) do ren "%%~i" "%%~ni" |
| The Following User Says Thank You to Cesar82 For This Useful Post: | ||
KaktoR (18-05-2023) | ||
|
#11
|
||||
|
||||
|
Thanks this works
__________________
Haters gonna hate
|
|
#12
|
|||
|
|||
|
Hi all !
How can i get the installed app's path to 'DefaultDirName' ? I have a reg-entry : Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\ Windows\CurrentVersion\Uninstall\MyApp] "InstallLocation"="D:\\MyProgram" Theoretically in InnoSetup's [setup] section DefaultDirName={reg:HKLM64\HKEY_LOCAL_MACHINE\SOFT WARE\Microsoft\Windows\CurrentVersion\Uninstall\My App, InstallLocation} should do the job. But no... Any idea ? Note : (there are "spaces" in the example paths,etc. Its only visible here,dont know why. I my script they doesnt exists. No matter.) |
|
#13
|
||||
|
||||
|
Quote:
Code:
DefaultDirName={reg:HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\My App_is1,InstallLocation|{pf}\My App}
UsePreviousAppDir=no
Last edited by Cesar82; 18-05-2023 at 07:01. |
| The Following User Says Thank You to Cesar82 For This Useful Post: | ||
shazzla (19-05-2023) | ||
|
#14
|
|||
|
|||
|
Thank you very much!
I will try and report back ASAP ! Its working fine ! Thanks !
Last edited by shazzla; 19-05-2023 at 02:35. |
|
#15
|
||||
|
||||
|
01.how to show Component Page before the Select Dir Page (without creating custom forms or anything like that) in Inno setup 5.5.1 ee2 version?
02.how to calculate the required disk space based on the components selected and show in gigabyte on Component page in Inno setup 5.5.1 ee2 version? I actually found an answer to this. But it doesn't work. If someone gives an answer to these two, it will be a great help <3 Code:
var
Component1Size: Extended;
Component2Size: Extended;
// Add variables for each component as needed
procedure InitializeWizard;
begin
Component1Size := 1048576;
Component2Size := 2097152;
// Assign sizes for other components if needed
end;
function GetTotalSize: String;
var
TotalSize: Extended;
begin
TotalSize := 0;
if WizardForm.ComponentsList.Checked[0] then
TotalSize := TotalSize + Component1Size;
if WizardForm.ComponentsList.Checked[1] then
TotalSize := TotalSize + Component2Size;
// Add similar lines for other components if needed
Result := FormatFloat('#,##0.00', TotalSize / 1024 / 1024 / 1024); // Convert bytes to gigabytes
end;
procedure ComponentsPageOnNextButtonClick(Sender: TWizardPage; var Continue: Boolean);
begin
if Sender.ID = wpSelectComponents then
WizardForm.DiskSpaceLabel.Caption := 'Required disk space: ' + GetTotalSize + ' GB';
end;
|
![]() |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| INNO TROUBLESHOOT - Tutorials and Answers about INNO Setup | REV0 | Conversion Tutorials | 129 | 21-05-2021 05:51 |
| INNO TUTORIAL - Using Unicode and ANSI Versions of INNO Setup | REV0 | Conversion Tutorials | 51 | 26-03-2015 06:57 |
| Frequently Asked Questions | Joe Forster/STA | PC Games - Frequently Asked Questions | 0 | 29-11-2005 09:48 |