Recent

Author Topic: Windows... fun, bugs and videotape  (Read 334 times)

440bx

  • Hero Member
  • *****
  • Posts: 955
Windows... fun, bugs and videotape
« on: April 25, 2019, 03:29:30 am »
Hello,

I ran into something (mostly) amusing.... I thought I would warn those who program for Windows about.

Most of us know that naming a program "setup<something>" or "install<something>" isn't a good idea unless you are really installing or setting up something.  Windows is a bit "particular" about programs named that way.

There is an API function  named "GetPhysicallyInstalledSystemMemory" (which BTW, is missing in FPC).  I wanted to see how it would behave in different situations, for that I made a little test program "creatively" named _GetPhysicallyInstalledSystemMemory.

The results are interesting and amusing...

First, Windows sees that "install" string in the name of the program (never mind that it's buried in the name) and decides to invoke User Account Control to make sure you're ok with that thing changing something in your installation.  Of course, that happens only if you are running the thing as a limited user.  If you try to debug that thing using Lazarus and GDB, GDB will be very unhappy about UAC getting in the way.

And, that is not the end of the fun... that seems to happen only in 32bit.  If you compile the program for 64bit, UAC seems happy to ignore it even if you are a limited user.   This makes GDB happy.

Attached is the little test program for anyone who wants to have some fun with it.  Rename it from "GetPhysicallyInstalled" to "GetPhysicallyInst" (or have two copies with the different names) and watch what happens when you run the thing.  Try debugging them :-)

Have fun!.


using FPC v3.0.4 and Lazarus 1.8.2 on Windows 7 64bit.

ASBzone

  • Full Member
  • ***
  • Posts: 226
  • Automation leads to relaxation...
    • BrainWaveCC Utilities
Re: Windows... fun, bugs and videotape
« Reply #1 on: April 25, 2019, 04:05:39 am »
Fine...  I'll bite this weekend. :)
-ASB: https://www.BrainWaveCC.com

Lazarus v2.0.3 r61485 / FPC v3.2.0-beta-r42306 (via FpcUpDeluxe) -- Windows 64-bit install w/32-bit cross-compile
Primary System: Windows 10 Pro x64, Version 1903 (Build 18362.116)
Other Systems: Windows 10 Pro x64, Version 1809 or greater

ASerge

  • Hero Member
  • *****
  • Posts: 1303
Re: Windows... fun, bugs and videotape
« Reply #2 on: April 25, 2019, 06:27:04 am »
Add to source {$R *.res} and in Project Options check "Use manifest...". The manifest tells Windows that the application is new and does not need to check the application name.

440bx

  • Hero Member
  • *****
  • Posts: 955
Re: Windows... fun, bugs and videotape
« Reply #3 on: April 25, 2019, 07:35:54 am »
Add to source {$R *.res} and in Project Options check "Use manifest...". The manifest tells Windows that the application is new and does not need to check the application name.
Very nice Serge.  I didn't think of using a manifest for that but, it makes perfect sense.

Thank you!.
using FPC v3.0.4 and Lazarus 1.8.2 on Windows 7 64bit.