Compiled BBC SDL creates multiple Registry entries

Discussions related to the supplied tools and add-in utilities
mavison
Posts: 34
Joined: Tue 03 Apr 2018, 17:27

Compiled BBC SDL creates multiple Registry entries

Post by mavison »

When a BBC SDL program is compiled into an exe, and run on Windows, it extracts the exe into a new directory
C:\Users\<username>\AppData\Local\Temp\BBCxxxx.tmp\
where xxxx seems to be a random set of four 0-F characters.

I think it then calls the bbcsdl.exe program in that directory to run the application progam, also in that temp directory.

This provokes Windows into creating two (or three) registry entries, with subkeys of:
HKCU\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\MuiCache
with Data Item names starting:
C:\Users\<user>\AppData\Local\Temp\BBCxxxx.tmp\bbcsdl.exe.
The Item ending ApplicationCompany contains a Data Value of "R.T.Russell"
The Item ending FriendlyAppname contains a Data Value of "BBC Basic for SDL 2.0"
Plus, if the exe is not Authorised, another subkey of:
HKCU\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Compatibility Assistant\Store
With a Data Item name of:
C:\Users\Martin\AppData\Local\\Temp\BBCD64.tmp\bbcsdl.exe with a hex value.

However, when the program is run again, the BBCxxxx is a different value, and so ANOTHER pair of registry entries are created.

Over time, because the original BBCxxxx.tmp directory is deleted when the application ends, those many registry entries (and I found hundreds) become a "Missing MUI Reference" or "Application Paths Isssue" as they are redundant.

Is there any way to avoid or remove these redundant registry entries?
I can get the value of BBCxxxx using the @dir$ variable, but the only way to delete the entries from the applicatoion that I can see might be to generate a .reg file and then execute it.

Could/Should the bbcsdl.exe program delete the registry keys at the time it deletes the temporary directory?
Or Could/Should the name be changed from the variable BBCxxxx to a constant - perhaps the App Name?

Unless any other ideas! Or am I doing something wrong?
Richard Russell
Posts: 272
Joined: Tue 18 Jun 2024, 09:32

Re: Compiled BBC SDL creates multiple Registry entries

Post by Richard Russell »

mavison wrote: Fri 15 Nov 2024, 16:14 However, when the program is run again, the BBCxxxx is a different value, and so ANOTHER pair of registry entries are created.
It's perfectly normal for files in %temp% to have different names every time a program is run, they are after all 'temporary' files. Indeed, the names which BBCSDL uses for these files are generated by the Wn32 API function GetTempFileName().

So whilst I have no idea why those registry entries are being created, it's presumably what Windows does with all temporary files and therefore nothing specifically to do with BBCSDL and nothing to worry about.
Could/Should the bbcsdl.exe program delete the registry keys at the time it deletes the temporary directory?
Absolutely not. BBCSDL isn't at all unusual in the way it creates and uses temporary files - except perhaps that it does actually bother to delete some of them, whereas many applications don't. :roll:
Or Could/Should the name be changed from the variable BBCxxxx to a constant - perhaps the App Name?
That wouldn't work - it would make it impossible to run multiple copies of the same app concurrently, something crucial for BBC BASIC programs because it's often the easiest way of benefitting from a multicore CPU.

I don't know what strategy (if any) Windows uses for clearing out the %temp% folder, other than the user doing so manually (Linux, by contrast, empties the equivalent directory on every reboot, as far as I know). But presumably when the files are deleted the registry entries and removed too, otherwise that sounds like a bug.
mavison
Posts: 34
Joined: Tue 03 Apr 2018, 17:27

Re: Compiled BBC SDL creates multiple Registry entries

Post by mavison »

Thanks Richard. That clarifies what is going on and why.
I will check if the entries are removed after a re-boot - something I only do when necessary.
The large number I found was caused by a few days of successive development changes and tests!

It is certainly suprising that Windows does not delete the registry entries with the files, and may be a bug.
Richard Russell
Posts: 272
Joined: Tue 18 Jun 2024, 09:32

Re: Compiled BBC SDL creates multiple Registry entries

Post by Richard Russell »

mavison wrote: Fri 15 Nov 2024, 17:38 Thanks Richard. That clarifies what is going on and why.
I will check if the entries are removed after a re-boot - something I only do when necessary.
According to this the registry entries you are seeing are created by the Program Compatibility Assistant (PCA) when it detects "program installation errors due to version check mismatches, as well as run-time issues due to deprecated binaries and User Account Control (UAC) settings".

What is interesting is that whilst I do see some of those entries here, there are nowhere near the number there would be if a new entry was being created every time I run a 'compiled' BBCSDL program (there are only around 30 in total, there would be thousands in that case).

Indeed, 30 could easily be the number of times that the files in %temp% were not deleted for some reason. So I'm beginning to wonder whether there is something specific to your program(s) which is causing the files in %temp% not to be deleted when they should be.

This can happen if, for example, your program crashes rather than terminating cleanly. Have you had problems with your code crashing?