Jump to content

Windows Environment Update


Recommended Posts

Ok my question is simple and straight forward.

Have any of you ever messed with custom file type associations, if you have you realize the annoyances that plauge us that want it all in a single file with no user automation.

Hence leading to my question, I want to know if any of you have experimented with the Win32 API that does what (Explorer.exe Window)->&Tools->Folder &Options-->[File Types]->Advanced->Ok->Ok does.

Now what i'm wanting is not some high level user manipulation code that I know would be easy to impliment, because that's the way and about wrong way for what im doing.

What I DO want is something that refreshes the explorer shell like the folder options code does, SystemParametersInfo() was mentioned before in this sort of topic, but it seems more suited for background changing than icon file type association updating.

I know something like this exists, and i'm not afraid to do a bit of external C code and make an Auto It plugin if I HAVE to, but certainly one of you have read something like dllcall("users32.dll", ...) or such that updates the Shell.

Anyone many thanks to all that can help, and if it's relevant:

$Project = "File Type Manager"

$Description = "An application that lets users set up file type associations with real time updating in a low-level manner like regedit"

$AutoItVersion = "3.1.1.119(Beta)"

Edited by axpen
Link to comment
Share on other sites

its in Help..........

Envupdate()

Yes that function is the closest to what I need as far as implemented AutoIt functions, but it doesn't update the Shell, only the environments variables

Link to comment
Share on other sites

I also think I should make it clear that I know Win32 API decently well and have messed with SystemParametersInfo before and noticed that it's only for user profile settings and things of that nature, besides that function was not meant for shell updating in pertinence to file association and things of that nature.

Link to comment
Share on other sites

I think this may do it with that SHChangeNotify Win32 API function, which was EXACTLY what I was looking for, i'll test it out then get back on whether or not it works, thanks for your help and your time though!

Link to comment
Share on other sites

Score!, thats right on the money what I needed, if any of you need help with VERY simple compact Win32 API code my source goes as follows,

#NoTrayIcon
#include-once
#include <Constants.au3>

$shell = DllOpen("shell32.dll")

If Not $shell Then
    MsgBox($MB_ICONEXCLAMATION, "[Critical]", "Couldn't File Shell32.dll, this could indicate a BIG problem")
    Exit 1
EndIf

#comments-start
void SHChangeNotify(
    LONG wEventId,
    UINT uFlags,
    LPCVOID dwItem1,
    LPCVOID dwItem2
);
===
SHChangeNotify(
    SHCNE_ASSOCCHANGED, 0x8000000
    SHCNF_IDLIST, 0
    null,
    null
);
#comments-end

DllCall($shell, "none", "SHChangeNotify", "long", 0x8000000, "int", 0, "ptr", 0, "ptr", 0)
If @error <> 0 Then
    Switch @error
        Case 1
            MsgBox($MB_ICONEXCLAMATION, "[Critical]", "Unable To Use The DLL File")
            Exit 2
        Case 2
            MsgBox($MB_ICONEXCLAMATION, "[Critical]", "Unknown Return Type")
            Exit 3
        Case 3
            MsgBox($MB_ICONEXCLAMATION, "[Critical]", "Function Not Found In The DLL File")
            Exit 4
    EndSwitch
EndIf

DllClose($shell)

Of course that SHChangeNotify also works with other updates like forcing file attribute updates, if you are wondering where I got that 0x800.... from I got it from the C header file for MinGW/Dev-Cpp [Your dev-cpp folder]/include/shlobj.h it has all the headers for this function.

My other external resources where the Microsoft Platform SDK 2003, you can get the iso file from Microsofts web site, and I would link you to it, but their site just plain sucks for linking to (good or bad I don't know). Just go to Microsoft Platform SDK 2003 Google Search and dont go for the web install please, do yourself a favor and do the 400mb iso so you can burn it off. But I assume one could also search that header file or the value of the constant they need on MSDN, but if you have the PSDK then go to: ms-help://MS.PSDKSVR2003SP1.1033/shellcc/platform/shell/reference/functions/shchangenotify.htm

I hope this topic has, and will be, of use to you all, I, at some point, intend to make Win32 header files for AutoIt but have not done so yet.

Link to comment
Share on other sites

This has caused the most fascinating problem i've ever seen, its made my registy delete all file type's shell->(default) values, until I can figure this out i'd really recommend you all dont use it, although help on figuring out why this happened would be nice ;P

Edited by axpen
Link to comment
Share on other sites

This has caused the most fascinating problem i've ever seen, its made my registy delete all file type's shell->(default) values, until I can figure this out i'd really recommend you all dont use it, although help on figuring out why this happened would be nice ;P

Well regardless of whether or not this is on topic I have found a way to resolve the issue if you accidentally did run my code, just kill explorer.exe and restart it again (or reboot), sorry for any computers that messed up, and any help as to whether this is just me or is it all who try my code, (BACKUP REGISTRY FIRST IF YOU ARE A NICE PERSON WHO WANTS TO HELP ME :)).

But anywho any help as to why this is so buggy would be VERY much appriciated!!!

--Edit:

Another side note though, isn't this just a notification thing?, windows just gets notified and then calls the updater... right? Well does anyone out there know the updater windows calls or is it just a matter of windows updates all devices manually?

Edited by axpen
Link to comment
Share on other sites

Ok I got the bugs worked out, aparently it was something with my computer?

The final code is:

#NoTrayIcon
#include-once
#include <Constants.au3>

Dim Const $SHCNE_ASSOCCHANGED = 0x8000000
Dim Const $SHCNF_IDLIST = 0
Dim Const $NULL = 0

DllCall("shell32.dll", "none", "SHChangeNotify", "long", $SHCNE_ASSOCCHANGED, "int", $SHCNF_IDLIST, "ptr", 0, "ptr", 0)
If @error <> 0 Then
    Switch @error
        Case 1
            MsgBox($MB_ICONEXCLAMATION, "[Critical]", "Unable To Use The DLL File")
            Exit 2
        Case 2
            MsgBox($MB_ICONEXCLAMATION, "[Critical]", "Unknown Return Type")
            Exit 3
        Case 3
            MsgBox($MB_ICONEXCLAMATION, "[Critical]", "Function Not Found In The DLL File")
            Exit 4
    EndSwitch
EndIf

If someone could help me determine if this is good code or in some way buggy (you don't have to test my code if you dont trust it) just by looking at it or testing it, if you do test it though BACK UP YOUR REGISTRY FIRST, then if it goes buggy, reboot and reimport your registry, although I wouldn't recommend testing it unless you think you know what it does and are sure it's safe! Anywho thanks for all the help thus far guys =)!!!

Edited by axpen
Link to comment
Share on other sites

I think i've come to the conclusion that it was just my computer, i've tested it in Windows 98SE and on other Windows XP installations and it works fine. So any input on this would be appriciated but the code should be safe now.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...