Our server costs ~$56 per month to run. Please consider donating or becoming a Patron to help keep the site running. Help us gain new members by following us on Twitter and liking our page on Facebook!
Current time: April 28, 2024, 11:46 am

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Coder needed.
#1
Coder needed.
Before I pull all my hair out in utter frustration, is it possible for someone to write a small programme (Windows exe file) that will allow me to change the associations of file types.

For example, if I called it with the parameters .mp3 and D:\player.exe like so..

FileTypeChanger.exe mp3 D:\player.exe

It would change the association for all *.mp3 files so they now open with player.exe

I have been mucking around with the registry all day and no matter what I do, Delphi will not let me change the parts that I need to. Probably an administrator/access denied thing, I don't know.

However, it really makes me mad that Zoom Player, DIVX Player and WMP seem to have no problem with this, supposedly simple task and yet I'm getting nowhere!!! Angry
[Image: cinjin_banner_border.jpg]
Reply
#2
RE: Coder needed.
Does this help?

REF: http://stackoverflow.com/questions/45850...-elevation
Slave to the Patriarchy no more
Reply
#3
RE: Coder needed.
Fraid not.. It seems no matter how much I fiddle with the registry it puts things back the way they were. Even when it explicitly says to open avi files with my programme in the registry it still opens them with whatever was assigned prior. What ever I do seems to have no effect no matter how obvious and logical it seems.

Might leave it for now before I explode, but thanks for the effort Great
[Image: cinjin_banner_border.jpg]
Reply
#4
RE: Coder needed.
I suspect that changing file associations is a super-user activity.

Here's the braindead simple reason why -

A trojan horse, run within a user account (so it's not out of control), can change the file associations to ensure it handles/steals the files handled by other applications. That is not only a security breach for other users, but even if one had isolated file associations to a per user, you'd have these issues:
- If all associations can be overridden per user, then a malicious association for things like text files, etc, might change how the explorer shell interacts and allow for a privilege escalation attack.
- If all non-essential (non-blacklisted) associations can be changed, then you probably end up fucking up legacy programs, as their associations (that their components may depend on) can be fucked with.

One of the SO answers correlates:
"It looks like only the admin can change the association globally. "

However, some people try to do file association registry manipulation (requires admin -- just give the per-user thingy up, as other apps like Windows Media Player may reset the associations).
REF: http://superuser.com/questions/51503/del...g-reg-file

A thread in Tom's Hardware Forums from a Windows XP group:
REF: http://www.tomshardware.com/forum/60620-...er-account

So, I looked for Windows 7 supporting such and found nothing conclusive. Perhaps Tiberius has some ideas?

And Tom's Hardware Forum posters claim that Windows XP does not do this.
Slave to the Patriarchy no more
Reply
#5
RE: Coder needed.
It's certainly something to do with privileges and admin rights. However, I have no trouble with editing the registry to add a link in the context menu so you can right-click and 'Play with Hypercube' any file you like so I should also be able to do this. It's also got something to do with the fact that these associations have already been defined as well, as creating a new one from scratch, say a *.myext works perfectly :S

Bloody Microsoft! But hey, stubborn is my middle name!!
[Image: cinjin_banner_border.jpg]
Reply
#6
RE: Coder needed.
Except that the registry is fragmented into a per-user one (limited), a system one (for storing configs of drivers and shit) and a system-wide one for the stuff that doesn't fit in per-user -- like any installed program.

So while perhaps adding a few context menu changes is allowed, it may be that the file associations are firmly in the system-wide category -- which makes sense: it used to be that any program installed on a Windows system was installed for ALL users, so it makes sense that a critical segment like file association data would be lumped within the same secure areas that control the registration and defaults for system-wide programs.

You're fighting legacy design decisions, Dar. That's a tall order to overcome.
I had a few thoughts -- I recalled a thread where the user's file associations were not working despite other custom overrides working. The problem was that the file associations that he overrode pointed to the wrong location for the executable.

I suspect, however, that some other program, like WMP, is resetting your file assocs.
Slave to the Patriarchy no more
Reply
#7
RE: Coder needed.
Whoa, Who'd have thought it would be this simple? Computer

Code:
procedure TForm1.RegisterFileType(ExtName:String);
var
  a: byte;

begin
  a:=0;

  with TRegistry.Create do
  try
    RootKey := HKEY_CLASSES_ROOT;

    DeleteKey('\.avi\');

    if OpenKey('\.avi\', True) then begin
      WriteString('','avifile');
      WriteString('PerceivedType', 'video');
      WriteString('Content Type', 'video/avi');
    end;

    OpenKey('\.avi\OpenWithList\ehshell.exe\', True);

    if OpenKey('\.avi\OpenWithProgIds\', True) then
      WriteBinaryData('avifile', a, 1);

   if OpenKey('\avifile\shell\open\command\', True) then
      WriteString('', '"'+ParamStr(0)+'" "%1"');

    RootKey := HKEY_CURRENT_USER;

    DeleteKey('\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.avi\');

    if OpenKey('\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.avi\OpenWithProgids\', True) then
      WriteBinaryData('avifile', a, 1);

  finally
    Free;
  end;

  SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, 0, 0);
end;
[Image: cinjin_banner_border.jpg]
Reply
#8
RE: Coder needed.
For a program that calls external executables and manipulates the registry, you got off easy. Tongue
Slave to the Patriarchy no more
Reply



Possibly Related Threads...
Thread Author Replies Views Last Post
  Urgent help needed emjay 24 1761 February 23, 2023 at 5:25 pm
Last Post: zebo-the-fat
  Networking Guru Needed popeyespappy 5 465 October 9, 2021 at 2:53 pm
Last Post: Jehanne
  Tips for c++ [needed] SavageNerdz 21 7060 April 16, 2012 at 7:29 am
Last Post: Tiberius



Users browsing this thread: 1 Guest(s)