Recent

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

440bx

  • Hero Member
  • *****
  • Posts: 4030
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!.


(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

ASBzone

  • Hero Member
  • *****
  • Posts: 678
  • Automation leads to relaxation...
    • Free Console Utilities for Windows (and a few for Linux) from BrainWaveCC
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.2.7-ada7a90186 / FPC v3.2.3-706-gaadb53e72c
(Windows 64-bit install w/Win32 and Linux/Arm cross-compiles via FpcUpDeluxe on both instances)

My Systems: Windows 10/11 Pro x64 (Current)

ASerge

  • Hero Member
  • *****
  • Posts: 2242
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: 4030
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!.
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

 

TinyPortal © 2005-2018