Announcement

Collapse
No announcement yet.

IE-like shortcut

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • IE-like shortcut

    Hi, there --

    Found a discussion, how to create icons similar "My Computer", "My Documents" on desktop (active desktop - IE4 or Win98+)
    Quickly wrote a program. It works on my PC under Win2000, but remains questions.

    Code:
       #Compile Exe
       #Dim All
       #Register None
       #Include "win32Api.Inc"
    
       '% 101 ICON C:\Ltr.01\Ltr.Ico 
       ' Include own ico into resource file
       #Resource "~Tmp.Pbr"
    
       Type CLSID
          Data1 As Long
          Data2 As Integer
          Data3 As Integer
          Data4(7) As Byte
        End Type
    
       Declare Function CoCreateGuid Lib "OLE32.DLL" Alias "CoCreateGuid" (CLSID) As Long
       Declare Function CoInitialize Lib "ole32.dll" Alias "CoInitialize" (ByVal pvReserved As Dword) As Dword
       Declare Sub CoUninitialize Lib "ole32.dll" Alias "CoUninitialize"
       Declare Sub CoTaskMemFree Lib "ole32.dll" Alias "CoTaskMemFree" (pv As Dword)
    
       Function GetCLSID() As String
          Dim CLSID As CLSID
    
          CoCreateGuid CLSID
    
          If (CoCreateGuid(CLSID) = 0) Then Function = "{" + Hex$(CLSID.Data1, 8) + "-" + _
             Hex$(CLSID.Data2, 4)+ "-" + Hex$(CLSID.Data3, 4) + "-" + _
             Hex$(CLSID.Data4(0), 2) + Hex$(CLSID.Data4(1), 2) + "-" + _
             Hex$(CLSID.Data4(2), 2) + Hex$(CLSID.Data4(3), 2) + _
             Hex$(CLSID.Data4(4), 2) + Hex$(CLSID.Data4(5), 2) + _
             Hex$(CLSID.Data4(6), 2) + Hex$(CLSID.Data4(7), 2) + "}"
    
       End Function
    
       Function PbMain
          CoInitialize 0&
       
          Dim TmpAsciizL As Asciiz * %MAX_PATH, TmpAsciizS As Asciiz * %MAX_PATH, TmpString As String
    
          GetModuleFileName GetModuleHandle(ByVal 0&), TmpAsciizL, SizeOf(TmpAsciizL)
    
          GetShortPathName TmpAsciizL, TmpAsciizS, SizeOf(TmpAsciizS)
          TmpString = TmpAsciizS:  Replace "\" With "\\" In TmpString
    
          Dim CLSID As CLSID, cCLSID As String
    
          cCLSID = GetCLSID
          cCLSID = "{0784A9CA-54DC-4ACB-A8BF-C0CD9656D8FA}" ' <---- Comment it, when debug will be finished
    
          If Command$ <> "" Then MsgBox "Command Line: " + Command$: Exit Function
    
          Open "~tmp.reg" For Output As #1
          Print #1, "REGEDIT4"
          Print #1,  "[HKEY_CLASSES_ROOT\CLSID\" + cCLSID + "]"
          Print #1, "@=" + $DQ + "PB Test " + Time$ + $DQ
          Print #1, $DQ + "InfoTip" + $DQ + "=" + $DQ + "PB Test (InfoTip)" + $DQ
          Print #1, "[HKEY_CLASSES_ROOT\CLSID\" + cCLSID + "\DefaultIcon]"
          Print #1, "@=" + $DQ + TmpString + ",0" + $DQ ' <--- ,0 is no. of icon
    
          Print #1, "[HKEY_CLASSES_ROOT\CLSID\" + cCLSID + "\Shell]"
          Print #1, "[HKEY_CLASSES_ROOT\CLSID\" + cCLSID + "\Shell\Open]"
          Print #1, "[HKEY_CLASSES_ROOT\CLSID\" + cCLSID + "\Shell\Open\Command]"
          Print #1, "@=" + $DQ + TmpString + " Standart (Open)" + $DQ
    
          Print #1, "[HKEY_CLASSES_ROOT\CLSID\" + cCLSID + "\Shell\Something]"
          Print #1, "[HKEY_CLASSES_ROOT\CLSID\" + cCLSID + "\Shell\Something\Command]"
          Print #1, "@=" + $DQ + TmpString + " Something (do what you want)" + $DQ
    
          Print #1, "[HKEY_CLASSES_ROOT\CLSID\" + cCLSID + "\ShellFolder]"
          Print #1, $DQ + "Attributes" + $DQ + "=hex:00,00,00,00"
    
          Print #1, "[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Desktop\Namespace\" + cCLSID + "]"
          Print #1, "@=" + $DQ + "Any comment" + $DQ
    
          Close #1
    
          Shell "regedit /s ~tmp.reg"
          
          CoUninitialize
    
       End Function
    At first, I want to know, does this code works on another PCes / platforms (hope, that yes).

    Second. Can't refresh a desktop imm.

    Manually - right click on desktop, "refresh" - this works fine. But I guess that this is internal custom message.

    I tried to hide / to show icons on desktop, to send SETTINGCHANGE message to "progman" (and it's "Listview")- no refresh.
    If to change resolution and to come back (it's easy to do programatically) - refresh works, but it's not a nice method.

    Any ideas ?

    ------------------
    E-MAIL: [email protected]

  • #2
    Code:
    Semen--
       
    I'm working on this problem right now too.  Some research in
    a variety of locations has led me to write the following:
       
    %SHCNF_IDLIST        = &H0
    %SHCNE_ALLEVENTS     = &H7FFFFFFF???
    '====================
    FUNCTION RefreshDeskTop&()
    LOCAL pidl&
    ECODE& = SHGetSpecialFolderLocation(%HWND_DESKTOP, BYVAl %CSIDL_DESKTOP, BYVAL varptr(pidl&))
    if ECODE& = %NOERROR then
       SHChangeNotify %SHCNE_ALLEVENTS, %SHCNF_IDLIST, pidl&, 0&
       CoTaskMemFree BYVAL pidl&
       ECODE& = 0
    end if
    END FUNCTION
       
    I've been tied up with other work for a few days and haven't
    yet done much testing of the routine.  Any help from you
    would be appreciated.

    ------------------
    -- Greg
    [email protected]

    Comment


    • #3
      Greg --
      Thanks for pointing a way (correct, I hope).
      Question only, which message to send.
      I wasn't able to prove your sub to work under Win2000, IE 5.5.

      After some experiments I found that following works
      Code:
          %SHCNF_IDLIST       = &H0
          %SHCNE_ASSOCCHANGED = &H08000000&
          Declare Sub SHChangeNotify Lib "shell32.dll" Alias "SHChangeNotify" (ByVal wEventId As Long, ByVal uFlags As Dword, _
              dwItem1 As Any, dwItem2 As Any)
      
           SHChangeNotify %SHCNE_ASSOCCHANGED, %SHCNF_IDLIST, ByVal 0, ByVal 0
      I didn't test under another OSes. I will do this after reconstruction of main code (to use regedit is good, but w/o it much better )
      Hope that this message should stimulate Explorer in all OSes (because it should show "new" icons).

      ------------------
      E-MAIL: [email protected]

      Comment


      • #4
        Code:
        Semen--
        
        Very sorry to have omitted this item:
              
        DECLARE FUNCTION SHChangeNotify LIB "SHELL32.DLL" ALIAS "SHChangeNotify" _
                       (EventID AS DWORD, Flags AS DWORD, dwItem1 AS DWORD, dwItem2 AS DWORD)
        ------------------
        -- Greg
        [email protected]

        Comment

        Working...
        X