-
Content Count
1073 -
Joined
-
Last visited
-
Days Won
23
Everything posted by aehimself
-
Help needed in testing emulated GetTickCount32/64
aehimself replied to Kas Ob.'s topic in Algorithms, Data Structures and Class Design
Found it! The code I used could not be more simple... program Project1; {$APPTYPE CONSOLE} {$R *.res} uses System.SysUtils; function GetTickCount64Emu: UInt64; const KUSER_BASE_ADDRESS = $7FFE0000; //KUSER_BASE_ADDRESS_KERNEL_MODE =$FFFFF78000000000; //in case it is needed begin Result := (PUInt64(KUSER_BASE_ADDRESS + $320)^ * PCardinal(KUSER_BASE_ADDRESS + $4)^) shr 24; end; begin try WriteLn(GetTickCount64Emu); ReadLn; except on E: Exception do Writeln(E.ClassName, ': ', E.Message); end; end. And it resulted 5283539281 with 61 days, 3.5 hours of uptime on a 32-bit Windows Server 2003 R2: -
Help needed in testing emulated GetTickCount32/64
aehimself replied to Kas Ob.'s topic in Algorithms, Data Structures and Class Design
@Kas Ob. The VM is now at 61 days of uptime. I'm having a bit of trouble compiling an EXE which actually executes on Windows 2003... I remember having to change something somewhere in the IDE / project options. If you know the solution let me know - it might be quicker than me attempting to research. -
This is the unit I use before my application will be updated. It lists the PIDs of instances of the same executable. It's not exactly what you need but with a small modification you can get it to work. CommandLineParameters (in uCommandLineParameters) is a singleton with easy access to general command line information... you safely can throw it out from your version. Unit uOtherInstances; Interface Uses System.SysUtils; Procedure TerminateOtherInstances; Function OtherInstances: TArray<Cardinal>; Implementation Uses WinApi.Windows, WinApi.TlHelp32, uCommandLineParameters; Type PTOKEN_USER = ^TOKEN_USER; Function GetUserAndDomainFromPID(inPID: Cardinal; Var User, Domain: String): Boolean; Var phandle, hToken: THandle; cbBuf: Cardinal; ptiUser: PTOKEN_USER; snu: SID_NAME_USE; UserSize, DomainSize: DWORD; bSuccess: Boolean; Begin Result := False; phandle := OpenProcess(PROCESS_QUERY_INFORMATION, False, inPID); If phandle = 0 Then Exit; // EnableProcessPrivilege(ProcessHandle, 'SeSecurityPrivilege', True); Try If Not OpenProcessToken(phandle, TOKEN_QUERY, hToken) Then Exit; Try bSuccess := GetTokenInformation(hToken, TokenUser, nil, 0, cbBuf); ptiUser := nil; While Not bSuccess And (GetLastError = ERROR_INSUFFICIENT_BUFFER) Do Begin ReallocMem(ptiUser, cbBuf); bSuccess := GetTokenInformation(hToken, TokenUser, ptiUser, cbBuf, cbBuf); End; Finally CloseHandle(hToken); End; If Not bSuccess Then Exit; Try UserSize := 0; DomainSize := 0; LookupAccountSid(nil, ptiUser.User.Sid, nil, UserSize, nil, DomainSize, snu); If (UserSize = 0) Or (DomainSize = 0) Then Exit; SetLength(User, UserSize); SetLength(Domain, DomainSize); If Not LookupAccountSid(nil, ptiUser.User.Sid, PChar(User), UserSize, PChar(Domain), DomainSize, snu) Then Exit; Result := True; User := StrPas(PChar(User)); Domain := StrPas(PChar(Domain)); Finally FreeMem(ptiUser); End; Finally CloseHandle(phandle); End; End; Function ProcessBelongsToUser(Const inPID: Cardinal; Const inUser: String): Boolean; Var domain, user: String; Begin Result := GetUserAndDomainFromPID(inPid, user, domain) And (user = inUser); End; Function OtherInstances: TArray<Cardinal>; Var len: DWord; user, exe: String; success: Boolean; psnapshot: THandle; pe: TProcessEntry32; currentpid: Cardinal; Begin exe := CommandLineParameters.ExeName.ToLower; currentpid := GetCurrentProcessId; len := 256; SetLength(user, len); If Not GetUserName(PChar(user), len) Then RaiseLastOSError; SetLength(user, len - 1); user := user.ToLower; SetLength(Result, 0); psnapshot := CreateToolhelp32Snapshot(TH32CS_SNAPALL, 0); Try pe.dwSize := SizeOf(pe); success := Process32First(psnapshot, pe); While success Do Begin If (pe.th32ProcessID <> currentpid) And (String(pe.szExeFile).ToLower = exe) And (CommandLineParameters.Portable Or ProcessBelongsToUser(pe.th32ProcessID, user)) Then Begin SetLength(Result, Length(Result) + 1); Result[High(Result)] := pe.th32ProcessID; End; success := Process32Next(psnapshot, pe); End; Finally CloseHandle(psnapshot); End; End; Procedure TerminateOtherInstances; Var pid: Cardinal; phandle: THandle; Begin For pid In OtherInstances Do Begin phandle := OpenProcess(PROCESS_TERMINATE, False, pid); If phandle = 0 Then RaiseLastOSError; Try TerminateProcess(phandle, 1); Finally CloseHandle(phandle); End; End; End; End.
-
Help needed in testing emulated GetTickCount32/64
aehimself replied to Kas Ob.'s topic in Algorithms, Data Structures and Class Design
Give me a couple of days: I'll let the admin know NOT to touch either this one or the host 🙂 -
You also can use TDimPanel: Blocking the access would simply require you to set .Visible to True, plus you can cover only parts of your window as well.
-
Delphi 12.2 code editor blinks for every key I press
aehimself replied to Clément's topic in Delphi IDE and APIs
RSS-1824 was already open about this issue . No solutions, no workarounds yet. Just fyi. -
I had to fire up my dev machine so I did a small test for you. The following code can be simplified a lot but at least it's easy to see what's going on: procedure TForm1.Button1Click(Sender: TObject); Var fulljson, group1, items: TJSONObject; enumpair: TJSONPair; begin fulljson := TJSONObject(TJSONObject.ParseJSONValue(Memo1.Lines.Text)); If Not Assigned(fulljson) Then Exit; Memo2.Lines.Add('JSON parsed successfully.'); group1 := TJSONObject(fulljson.GetValue('Group1')); If Not Assigned(group1) Then Exit; Memo2.Lines.Add('Group1 found!'); For enumpair In group1 Do Begin Memo2.Lines.Add('Found ' + enumpair.JsonString.Value + ' under Group1'); items := TJSONObject(enumpair.JsonValue); Memo2.Lines.Add('ImgHot: ' + items.GetValue<String>('ImgHot')); Memo2.Lines.Add('ImgNormal: ' + items.GetValue<String>('ImgNormal')); Memo2.Lines.Add('ImgChannel: ' + items.GetValue<String>('ImgChannel')); Memo2.Lines.Add('Caption: ' + items.GetValue<String>('Caption')); End; It successfully walks through your JSON file:
-
DelphiLSP.Exe version 11.1 vs 12.2
aehimself replied to Gert Scholten's topic in Delphi IDE and APIs
The 64 bit DelphiLSP simply hangs on my mid-sized project, just spins the progress bar over and over again, still saying 0% is done. 32 bit works fine on the same project, performance feels about the same as in 12.1. This is from the 12.2 document, fyi work on most symbols, sometimes resolves 🙂 Unfortunately yes, LSP needs some work to be actually good. Ctrl-click often doesn't work, jiggly lines at wrong places, errors in editor but project compiles... It can be lived together with if you already got used to Delphi's quirks 🙂 -
I don't know if it was included in Delphi 10.1 or it came later, but you can use TJSONObject in the System.JSON unit. You'll find plenty of examples to get you started on how to process your specific document.
-
Delphi 12.2 code editor blinks for every key I press
aehimself replied to Clément's topic in Delphi IDE and APIs
That was my first guess. Flickering is still present even if it's off. -
Delphi 12.2 code editor blinks for every key I press
aehimself replied to Clément's topic in Delphi IDE and APIs
I'm only asking because the quick peek I took at Delphi 12.2 until now showed the same symptom. And I'm using RDP to access the machine Delphi is installed on, too. -
Delphi 12.2 code editor blinks for every key I press
aehimself replied to Clément's topic in Delphi IDE and APIs
@Clément Are you accessing Delphi through MsTSC? -
In the prehistoric times, you could download the MySQL C library from their website. Then they changed to the installer-type (download installer, select Connector-C, install 32 bit, copy file, uninstall 32 bit, install 64 bit copy file, uninstall everything). Now it's even worse. The installer now offers only 6.1.11, but you still can have the latest by downloading MySQL server and copying the file from the Lib folder. My 64 bit Delphi apps are using it happily; but that's only 64 bit, and there's no 32 bit version of MySQL anymore. The question is: is there a way to get the latest (currently 8.0.18) libmysql.dll in 32 bits? P.s.: I know that libmariadb is a drop-in replacement but I'd prefer the original if possible somehow / somewhere.
-
Both of libmysql.dll-s in HeidiSQL's bundle seems to have the PE L header, suggesting they are indeed 32-bit: I'll check on them later if they work properly. It would be nice to know the source of these but I have doubts they are official.
-
Seems to be like encoding. Make sure that encoding is set properly, and also if the text gets scrambled at logging or not (check .AsBytes property and verify if value is a valid UTF8 / UTF16 / ANSI string)
-
ANN: Better Translation Manager released
aehimself replied to Anders Melander's topic in Delphi Third-Party
@Anders Melander Is an auto-update feature planned for BTM in the future? That, and a filter to only show untranslated and/or changed entries would make BTM a perfect tool imo. Thank you very much for it! -
VCL or CLX? How do I know what type of application I'm designing in Delphi 7. I'm a beginner.
aehimself replied to Miguel Jr's topic in Delphi IDE and APIs
Unsupported definitely. But dead...? I hear it's the go-to version for lots of legacy codebases. -
Parsing Json to retrieve nested record
aehimself replied to bzwirs's topic in Network, Cloud and Web
recenum and tubeenum are initialized automatically by Delphi during the For .. In ... cycle. You don't need to "obtain" them. Similar to: Var stringarray: TArray<String>; stringenum: String; Begin [...] // stringenum is "uninitialized" at this moment For stringenum In stringarray Do // stringenum is now initialized and contains the next element in the array [...] In the original snipplet values are being assigned at: For recenum In records Do Begin [...] For tubeenum In tubes Do -
Is there a way to check is the "user Idle" (no interaction)
aehimself replied to Tommi Prami's topic in Windows API
Nice insights! I'll make some updates once I managed to set my dev VM up (I'm in the middle of switching to Linux on my daily driver atm...) -
Is there a way to check is the "user Idle" (no interaction)
aehimself replied to Tommi Prami's topic in Windows API
I have a component which detects and attempts to "break" the idle status. https://github.com/aehimself/AEFramework/blob/master/AE.Comp.KeepMeAwake.pas Works fine even in remote desktop connections. -
Based on this, you can use the old paint.exe to force-launch the new Paint 3D: mspaint "C:\TEMP\A.jpg" /ForceBootstrapPaint3D As far as I know though even "modern" apps have executables they just reside in unimaginable places somewhere under your local appdata folder. Unfortunately though I can not confirm this as Paint 3D is one of the first things I uninstall from a new Windows 🙂
-
TStringStream inconsistent results
aehimself replied to Mark Williams's topic in RTL and Delphi Object Pascal
Also, there's no real benefit of copying your memory stream to a string stream and loading it to the IXMLDocument that way; it just adds one more point-of-failure when it comes to encoding (if not specified, TStringStream considers the data to be ANSI encoded): constructor TStringStream.Create; begin Create('', TEncoding.Default, False); end; What I'd do is save both binary data to the disk and inspect them with a HEX editor. It will quickly reveal the differences what you might have to adjust, like encoding differences, absence / presence of BOMs, etc. -
I know, I should write some documentation about most of my stuff... Until then, there's a minimum example on how to create a sample update file in this post. However, I started thinking. If you simply want to show it, why not a simple TMemo, which loads the information from a .TXT file / embedded resource / HTTP?
-
Do you want to embed this into your .exe version information or just to display it somewhere? I'm asking because TAEUpdateFile which comes with TAEUpdater bundles all this information - you just have to fill them. The method FileVersion returns most what you'll need.
-
If there is a new patch / version available it will always show up in this forum. This is how I get informed 🙂