Delphi 2009: How to communicate between Windows service & desktop application under Vista?

The way to go is named pipes, you’ll probably have to take a look at the communication across different Integrity levels. This article explores how to do this in vista. Although it’s written in c++ it’s just basic Windows API calls, so it should translate fast enough to Delphi. If you want to search for … Read more

How to prevent Vista from requiring elevation on patch.exe?

The problem is that your application does not contain an assembly manifest with a requestedExectutionLevel. Background All correctly written Windows applications are required to have an assembly manifest. And starting in 2006 one of the elements you’re required to have is a requestedExecutionLevel that specifies if your application can only function if the user is … Read more

Failed to update .mdf database because the database is read-only (Windows application)

The big thing that changed between Windows XP and Windows Vista/7 is the introduction of UAC which means that users, even if created as administrators, don’t routinely have read/write access to “important” locations such as the %programfiles% (Usually C:\Program Files or C:\Program Files (x86)) directory. This is why your application works on Windows XP and … Read more

How to associate a program with a file type, but only for the current user?

If you want to register the association for every user, write your data to HKEY_LOCAL_MACHINE\Software\Classes If you want to register the association for the current user only, write your data to HKEY_CURRENT_USER\Software\Classes This is how to do the latter: with TRegistry.Create do try RootKey := HKEY_CURRENT_USER; if OpenKey(‘\Software\Classes\.myfile’, true) then WriteString(”, ‘MyAppDataFile’); if OpenKey(‘\Software\Classes\MyAppDataFile’, true) … Read more

Disabling UAC programmatically

Set the EnableLUA DWORD value in HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System to 0 and reboot. this will disable UAC without a problem, i would do it to all your users, with or without permission is up to you, because the vista UAC is so horrid that i do believe the less people that have it on the better (in … Read more

How to draw custom button in Window Titlebar with Windows Forms?

The following will work in XP, I have no Vista machine handy to test it, but I think your issues are steming from an incorrect hWnd somehow. Anyway, on with the poorly commented code. // The state of our little button ButtonState _buttState = ButtonState.Normal; Rectangle _buttPosition = new Rectangle(); [DllImport(“user32.dll”)] private static extern IntPtr … Read more

How do you run a command as an administrator from the Windows command line?

All you have to do is use the runas command to run your program as Administrator (with a caveat). runas /user:Administrator “cmdName parameters” In my case, this was runas /user:Administrator “cmd.exe /C %CD%\installer.cmd %CD%” Note that you must use Quotation marks, else the runas command will gobble up the switch option to cmd. Also note … Read more