-
Content Count
1053 -
Joined
-
Last visited
-
Days Won
23
Everything posted by aehimself
-
Holy mess, I skipped only one day with my gadget addiction and I came back to see my E-mail inbox exploded! As it was mentioned countless times, you must get a stack trace of where the error happens. Without that most probably we are all looking at the wrong place. Far from ideal, but SendMessage works in this scenario. I doubt that Win7 - Win10 will be an issue either; I am testing most of my code with everything from Windows 2000 and up and so far only new features (which does not exist in earlier editions) caused headache. And just because it's a framework, don't be afraid to touch it! At work we have a similar setup - part of our legacy app's code is used as a base for many other applications. I started to sort out some basic leaks and you can not imagine what was buried deep below. A framework is the nothing but code, which can contain bugs even if thousands of other applications are using it. If you are absolutely sure you can not get a stack trace, at least pollute your methods with debug messages using a new logger with proper synchronization. When the AV occures, just look which method started and did not finish. Alas, using proper synchronization in your new debug logger might solve the synchronization issue (if it is a synchronization issue after all...) with those tiny-tiny delays. So yeah, reinventing the wheel is not a smart thing to do, if we have MadExcept and similar.
-
I'm using the standard System.JSON library. It supports everything I needed until now, except merging.
-
Read of address with a low number means a nullpointer exception; the code is attempting to access an already freed / uninitialized object. Did you manage to catch where the AV is raised or you just see it in the logs? I was suspecting that the thread's "stat" variable is overwritten and therefore relocated; but it's unlikely because 1, it would show a random address, not 1. 2, thanks to @Anders Melander I remembered that SendMessage does not return until the message is processed. So unless "stat" can be written from the outside...
-
Do you name your Threads for debugging?
aehimself replied to Darian Miller's topic in Tips / Blogs / Tutorials / Videos
Yes, yes and yes. I have a custom TThread descendant, which sets it's own name to it's classname. Makes debugging a lot more easy than hunting for IDs. -
I used the WMI method as it was easier and I already had wrappers for it. Just SELECT * FROM Win32_QuickFixEngineering in ROOT\CIMV2.
-
Using TFileStream to check if file is in use
aehimself replied to Patrick Hughes's topic in Algorithms, Data Structures and Class Design
Good to know; thanks for sharing, I'll try to keep this in mind if I'll have to use FileStream-s one day! -
Using TFileStream to check if file is in use
aehimself replied to Patrick Hughes's topic in Algorithms, Data Structures and Class Design
fmCreate, according to Delphi help = Create a file with the given name. If a file with the given name exists, override the existing file and open it in write mode. I don't use FileStreams that often, but won't you effectively null the contents...? I would go the old-school way; however I have no idea if it would work: Var f: File; Begin If Not FileExists('myfile') Then Exit(False); {$I-} AssignFile(f, 'myfile'); Append(f); Result := IOResult <> 0; If Not Result Then CloseFile(f); End; -
Sometimes we had this when using License Server activation and installing from an .ISO image. I personally never faced this issue, but my colleague succeeded by starting the network installer, importing the .slip file and then using the .ISO installer. And I thought these should be the same...? π
-
Why is ShowMesssage blocking all visible forms?
aehimself replied to Mike Torrettinni's topic in VCL
Yes, makes sense; did not think of this. What you can do is to have a TFrame with basic functionality (placeholder for the monitor, invisible panel, etc) and add a "pop out" button there. When you click it, you simply create a TForm and move the current TFrame on that new form. Just, don't forget to free the tabsheet π I was also experimenting with auto-docking tabsheets a while ago. When you drag them out they turned to forms automatically, and vice versa. Unfortunately though the performance was so bad (flickering and lagging) that I abandoned the idea. Most probably I was doing something wrong; you can look in this direction too instead of a pop-out button. Edit: Seems pretty easy, I don't know what I messed up before. Edit-edit: It works, but the flickering is still there when dragging around the "child" window; even if DoubleBuffered is on. If you don't want to watch the video: Set DockSite of the PageControl to True. Set DragKind of the "child" form to dkDock and in the OnClose event set the Action to caFree. Then, create your "child" forms like this: Var f: TForm2; begin f := TForm2.Create(Application); f.ManualDock(PageControl1); f.Show; End; -
Why is ShowMesssage blocking all visible forms?
aehimself replied to Mike Torrettinni's topic in VCL
Talking from an end-user perspective I'd go insane if one application would open tens of forms. I have one screen only and it will be polluted within seconds. What I would do is to have only one form, with a list on the left and a PageControl on the right. Instead of forms, create a new TabSheet for the monitors. When there is an alert, you can change the ImageIndex property to change the icon of the tab sheet; signaling the user that attention is needed. As for the "messages" I would put an invisible panel inside every tab sheet, on top of everything. It would contain only a TMemo and a button to dismiss. This way if multiple alerts are generated without interaction, you can append it to the memo instead of having 3-4 popup windows for a single monitor. -
Automatically make your PC wake up at a given time
aehimself replied to dummzeuch's topic in Tips / Blogs / Tutorials / Videos
Now this applies only to Windows as I'm not working with Linux machines, but the Windows Computer Browser service is basically collecting a bunch of broadcasted information and then others connect to it via TCP (source). If the activity-based startup is locked to an IP it will not be triggered by broadcast messages; the rest of the communication will be between other PCs and the current directory master. Alas, this only applies for standard services. My program attempting to ping this IP to see if it's alive or not will trigger the power on for sure. -
Problems downloading files from a FTP server using the ICS FTP Client. The DIR command has no carriage return or line feeds
aehimself replied to M-Brig's topic in VCL
If File Explorer is the standard Windows file management application which pops up when you click on My Computer / This PC; and you just type ftp://host_or_ip_of_device it's hardwired in the shell for sure. I am also certain that Microsoft did not maintain this Client as they saw the future in WebDav; not FTP; but to be honest it's irrelevant in your case. You said your only issue is that your device is inserting a null character at the end of each file upon listing, which you save to a file. I'm not sure if Delphi is handling #0 characters in strings since Unicode; but you can try: Var sl: TStringList; a: Integer; Begin sl := TStringList.Create; Try sl.Delimiter := #0; sl.LoadFromFile('MyList.lst'); For a := 0 To sl.Count - 1 Do // Do something with the file at sl[a] Finally sl.Free; End; End; Or... Uses System.IOUtils; Var sa: TArray<String>; fname: String; Begin sa := TFile.ReadAllText('MyList.lst').Split([#0]); For fname In sa Do // Do something with the file in fname End; and then using any FTP client component you issue a download request. Edit: It does. Var sa: TArray<String>; fname: String; Begin sa := String('Hello' + #0 + 'World' + #0 + 'Zero char' + #0 + 'separation').Split([#0]); For fname In sa Do ShowMessage(fname); End; works, popping up one segment at a time; so it should do the trick. -
By the definition from MSDN (https://docs.microsoft.com/en-us/windows/win32/api/exdisp/nn-exdisp-ishellwindows) "IShellWindows interface Provides access to the collection of open Shell windows." [...] "A Shell window is a window that has been registered by calling IShellWindows::Register or IShellWindows::RegisterPending." Which means that if I want to, I can register any application as a shell window and you will see it in your collection. Maybe this is what you mean "hidden" as it is an instance of a shell window, which is NOT an Explorer process...? Edit: I suppose you already read this: "If the type is VT_UI4, the value of index is interpreted as a member of ShellWindowTypeConstants" ...which leads you here: "SWC_EXPLORER An Windows Explorer (Explorer.exe) window. SWC_BROWSER An Internet Explorer (Iexplore.exe) browser window. SWC_3RDPARTY A non-Microsoft browser window. SWC_CALLBACK A creation callback window. SWC_DESKTOP Windows Vista and later. The Windows desktop." So I suppose you are handling these cases in your code...?
-
Automatically make your PC wake up at a given time
aehimself replied to dummzeuch's topic in Tips / Blogs / Tutorials / Videos
What periodic activity you mean? In normal circumstances a regular server (DHCP, DNS, File server) is not looking for offline clients. Regular protocols are not even looking for Clients at all as most of the actions are initiated by the Client. -
Automatically make your PC wake up at a given time
aehimself replied to dummzeuch's topic in Tips / Blogs / Tutorials / Videos
To be honest I never heard of this until now, but I'm sure our PCs do not support this (or - it's not enabled). I'll do my research on it; it would be an easier solutionfor sure. -
Sending commands only. I don't have any specific projects in mind; I just see the opportunities of a connection between a Delphi app and an Arduino. For the time being I'd just be interested in a hello-world type setup. Make an Arduino light an LED when you check a checbox on a Delphi form. I'll make my way from there, when I have anything specific in mind π
-
Nice! I also played around with Arduino boards (this is how I fixed my smoking Christmas tree lights on Christmas eve) and I love them a lot. I even minified a project to a single ATMega chip for extra efficiency. But there was one thing I was always wondered but never took the time to dig myself into... can I talk to this board with Delphi...? I don't want you to share mission critical parts, but can you give some hints on how you did it? Are you using standard Serial to USB and text commands? Or a custom interface?
-
Automatically make your PC wake up at a given time
aehimself replied to dummzeuch's topic in Tips / Blogs / Tutorials / Videos
While we were working from home the office building decided that it's a good time to test the electric breakers. This resulted someone having to travel on-site and turning all PCs on one-by-one on the whole floor. I started to experiment; my plan is to write a simple service application which is discovering PCs in a pre-defined range and provides a web interface where you can log on with your domain credentials and choose which PC you would like to wake up with WOL. If I get the green light from management I think this is going to be our solution. I'll have to test though, if a WOL broadcast packet actually works out-of-subnet or not; or what configuration is required on the network devices as I have no personal experience with this. -
Thank god we use XMLs in this case π
-
And that is an issue, if you ask me. To be honest I lost track a long time ago, but for a while the Windows Taskbar and the Desktop was hosted by an instance of the same explorer.exe process what you launched when you clicked on "My computer"; maybe Windows is using it for even more undocumented things (like specific background processes; which would answer why they just come and go). If your application requires to interact with an Explorer window, you should let your users to choose which one. But then again - this is how I think. Wrong. A process has multiple granted properties; like an executable NAME and a PID for example. All processes have that, having visible windows or not, being service applications or not, being launched under a svchost process or not. Depending on how you enumerate those, you get different properties available. I personally never used ShellWindows as I always went for EnumWindows or FindWindow what @Fr0sT.Brutal advised to you already. It's a bit more low level, but opens up tons of opportunities. And this part; I must totally have to agree with @David Heffernan. If someone anonymous on the Internet would tell you "Download my app, it's useful, you always can delete"... would you trust him/her? At this point noone really understands why you are doing what you are doing so they are unable to give you alternatives. Without an understandable code snipplet (e.g. I have no damn clue what "Do not forget Dispatch := ShellWindows.Item(i); is nil" means and I think I'm not alone) or a clear goal set... it just sounds like an other million dollar idea what SW developers are usually getting.
-
I quickly realized. It threw a nullpointer exception anyway because of embedded JavaScript. And XML does not have that π Our overgrown legacy system is talking to an other, overgrown legacy system through a custom protocol, transporting the XMLs in a beautified form. Now the issue is, that sometimes these two systems start to get misaligned because either of a 3rd overgrown legacy system, a bug in their software or a bug in ours. So after fixing a bug these information packets should be re-processed or re-sent. And as the protocol was designed you always need a reference to an earlier packet as well... quite complicated, resulting us having to save all communication between our software instances and their system. Originally, someone decided to keep the XMLs in a BLOB field in a table. Unfortunately the code is so big and disorganized (20+ years old) that changing the saving scheme would need a re-writing half our application plus the web interface. We know it should be done but we also know that it never will be done as the clients do not pay for refactoring. The good thing in legacy systems are the gems what you can find. My favorite goes like this: Function GetUserID: Integer; Begin Case MenuID Of 0: Result := -1; 1: Result := -1; 2: Result := -1; [...] 100: Result := -1; Else Result := -1; End; End; ... and oooooh, those sweet comments π Too bad that most of them are in Hungarian, otherwise I'd have posted them on DevHumor.
-
I know, just wanted bring a really negative example. Most of the CMS WYSIWYG editors are no exception though and since they love to use shared libraries I suppose webmail interfaces are guilty as well. As I mentioned I mainly work with XML, which is similar (but not the same) as HTML; and in XML the results are surprising already. Iβll go ahead and call minifying a compression method (a fairly inefficient one, though) from now on. As with most compressions the output heavily depends on the input; but usually the larger the input, the better the ratio becomes. The purpose of a compression is not to make it readable, and if it causes errors itβs a bug in the code. All Iβm saying is whether if itβs efficient or not - minifying is still viable as this is the only way the output is still accepted by the target software. Just out of curiosity Iβll run my XML minifyer on a HTML page and will post the results.
-
Oh, you would be surprised. The last WYSIWYG program that wrote clean HTML code was Front Page Express around 2000. My favorite was creating a simple page, saving it in Word 2003 as HTML and then manually trimming the waste out. I usually could save aywhere between 5 or 20 kilobytes, keeping the original design. Now imagine trimming the "useless" characters too, used only to make the code readable. We deal with XMLs mostly at work. As an example, a beautified XML is 687722 characters, the same minimized is 455528; that's about 33% "compression".
-
Hello all, After switching from D7 to D10.2 I re-wrote one of my multithreaded apps with proper OOP, using the "new" language features. Each thread has a work queue, which used to be a Array Of String, storing the properties separated with tabs. Now, the work queue is a TObjectList, and work queue items are classes, created upon adding, freed after successful processing. Everything works like a charm, there are no memory leaks reported whatsoever even after a stress-test of the work item part. After about a week of uptime my Windows 2000 test system reaches 0% of free memory and becomes unstable, requiring a reboot. Unfortunately there are a lot of factors to consider here: - The ESX host the test VM is running on was patched a couple of times (and because of that vmWare tools got updated on the guests) - The obvious, Array to TList and String to Class conversion - Only a Windows 2000 system is affected, Windows 2003 and above accepted the change well I will attempt to create a new Windows 2000 machine without vmWare tools to see if it makes any difference, however I believe that TList will be the root cause here; which got reinforced after seeing Did anyone met this symptom before? How can I be sure the root cause is my application and not the prehistoric OS? Maybe the combination of both? Is there a (even a hacky) way to force a Delphi application to release any currently not used memory? Thanks all!
-
So after weeks of attempting to find the guilty code piece I found nothing. Every allocation had a release pair, memory usage was perfectly consistent for close to a month. This combined with the fact that only one machine was affected means that whatever happened, it was not caused by my code (and therefore generics and classes) and was only a coincidence. And I think I already know what happened. So thanks all for the tips; at least we know that (even if it's unsupported) D10.3 applications are running happily (and correctly) on Windows 2000 too π