Jump to content

Creating icons that behave like My Computer, Inbox, or My Documents like icons.


Guest Mixture63
 Share

Recommended Posts

Guest Mixture63

In case you ever need this:

;Mixture63's demonstration of placing fixed icons on the desktop.

;This is an example of placing icons like My Documents and Inbox on the desktop.
;It will create a text file: C:\DesktopReadme.txt and then it will make an icon to open
;that Readme.txt in notepad on the desktop.

;Note: It may be neccessary to refresh your desktop afterwords.
;These icons can be deleted.

FileWrite("C:\DesktopReadme.txt","This is a text file.")

$CLSID = "{9213AC3E-BBCE-D91E-E999-AA9246B9CD9C}"

RegWrite("HKEY_CLASSES_ROOT\CLSID\"&$CLSID, "", "REG_SZ", "ReadMe")
RegWrite("HKEY_CLASSES_ROOT\CLSID\"&$CLSID&"\DefaultIcon", "", "REG_SZ", "Notepad.exe")
RegWrite("HKEY_CLASSES_ROOT\CLSID\"&$CLSID&"\shell", "", "REG_SZ", "")
RegWrite("HKEY_CLASSES_ROOT\CLSID\"&$CLSID&"\shell\Open", "", "REG_SZ", "Read")
RegWrite("HKEY_CLASSES_ROOT\CLSID\"&$CLSID&"\shell\Open\Command", "", "REG_SZ", "Notepad.exe C:\DesktopReadme.txt")

RegWrite("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\explorer\Desktop\NameSpace\"&$CLSID, "", "REG_SZ", $CLSID)

Just a simple example on how to create desktop icons that are like inbox:

They can't be moved into anywhere else but the desktop.

They don't goto recycle bin but instead are gona forever.

They can be shortcuts to other things but without the annoying little arrow icon.

ecetra.

Note: I could demonstrate how to do more things with it if you want, and if I feel like it at the time.

Edited by Mixture63
Link to comment
Share on other sites

Guest Mixture63

this is too leet for us ;)

1 question. what is that clsid and how do i get one ...

CLSID I think means Class Identifer but I am not totally sure.

You generate it randomly.

You could write a script in autoit to do that as a matter of fact.

A CLSID has is a string enclosed in {} with 5 sections delimited by dashes. You can use character 0-9 and A-F.

Section 1 had 8 characters.

Section 2, 3, and 4 has 4 characters.

Section 5 has 12 characters (If I recall correctly.)

I'll post a generator if you like.

When I get back, I will explain how the registry works for these kind of things.

Link to comment
Share on other sites

CLSID I think means Class Identifer but I am not totally sure.

You generate it randomly.

You could write a script in autoit to do that as a matter of fact.

A CLSID has is a string enclosed in {} with 5 sections delimited by dashes. You can use character 0-9 and A-F.

Section 1 had 8 characters.

Section 2, 3, and 4 has 4 characters.

Section 5 has 12 characters (If I recall correctly.)

I'll post a generator if you like.

When I get back, I will explain how the registry works for these kind of things.

coool.... i would like to see that also

8)

NEWHeader1.png

Link to comment
Share on other sites

CLSID I think means Class Identifer but I am not totally sure.

Correct.

You generate it randomly.

Not exactly. It's pseudo-random. Since all random generators are pseudo-random this is a given but in the case of an UUID, it's significant. A UUID/CLSID/GUID is supposed to be unique which means at any given point in time, nobody else will ever create and use that same combination so it is safe for you to use it on any and every machine ever made.

You could write a script in autoit to do that as a matter of fact.

Probably so, but there is an algorithm that must be used. It would be far simpler to create the requisite structure with DllStruct functions and DllCall() the CoCreateGUID API function.

A CLSID has is a string enclosed in {} with 5 sections delimited by dashes. You can use character 0-9 and A-F.

You don't "use" anything. The characters you see are the hex representation of the bytes that compose a UUID.

Section 1 had 8 characters.

Section 2, 3, and 4 has 4 characters.

Section 5 has 12 characters (If I recall correctly.)

A UUID is 16 bytes (128 bits) long. The common hexadecimal display notion involves displaying 4 bytes followed by a dash then 3 sections each 2 bytes followed by a 6 byte section, which is what you describe.

I'll post a generator if you like.

Again, a simple script wrapping the necessary DllStruct/DllCall stuff is all that is needed to make a "generator".

More information can be found here. UUID's aren't just something you can make up randomly. The formula needs to be followed so that the "Unique IDentifier" part of the name is true. And for those confused, CLSID and GUID are the same thing which are Microsoft's implementation of UUID.

Link to comment
Share on other sites

Guest Mixture63

I didn't want to use the Win API way of generating it or the alg because I wanted to make it myself.

;UID Generator by Mixture63

MsgBox(0, "Random UID", GenerateUID())

func GenerateUID()
    $Section1 = Hex(Random(0, 256^2, 1), 4) & Hex(Random(0, 256^2, 1), 4)
    $Section2 = Hex(Random(0, 256^2, 1), 4)
    $Section3 = Hex(Random(0, 256^2, 1), 4)
    $Section4 = Hex(Random(0, 256^2, 1), 4)
    $Section5 = Hex(Random(0, 256^2, 1), 4) & Hex(Random(0, 256^2, 1), 4) & Hex(Random(0, 256^2, 1), 4)
    
    return "{" & $Section1 & "-" & $Section2 & "-" & $Section3 & "-" & $Section4 & "-" & $Section5 & "}"
EndFunc

I had to restrict the size of the random number to 256^2 and the hex length to 4 otherwise the intepeter

has a pissy fit.

Registry explanation comming soon.

Edited by Mixture63
Link to comment
Share on other sites

But just using Random() is wrong. As I stated, there is an algorithm to it and all you are doing is generating a string that happens to look like a CLSID. This is wrong and is not guaranteed to create a unique identifier which is more or less the entire point of CLSID/GUID/UUID. If you want to roll your own, you at least have to use the algorithm, otherwise, you are generating garbage.

Link to comment
Share on other sites

In case you ever need this:

;Mixture63's demonstration of placing fixed icons on the desktop.

;This is an example of placing icons like My Documents and Inbox on the desktop.
;It will create a text file: C:\DesktopReadme.txt and then it will make an icon to open
;that Readme.txt in notepad on the desktop.

;Note: It may be neccessary to refresh your desktop afterwords.
;These icons can be deleted.

FileWrite("C:\DesktopReadme.txt","This is a text file.")

$CLSID = "{9213AC3E-BBCE-D91E-E999-AA9246B9CD9C}"

RegWrite("HKEY_CLASSES_ROOT\CLSID\"&$CLSID, "", "REG_SZ", "ReadMe")
RegWrite("HKEY_CLASSES_ROOT\CLSID\"&$CLSID&"\DefaultIcon", "", "REG_SZ", "Notepad.exe")
RegWrite("HKEY_CLASSES_ROOT\CLSID\"&$CLSID&"\shell", "", "REG_SZ", "")
RegWrite("HKEY_CLASSES_ROOT\CLSID\"&$CLSID&"\shell\Open", "", "REG_SZ", "Read")
RegWrite("HKEY_CLASSES_ROOT\CLSID\"&$CLSID&"\shell\Open\Command", "", "REG_SZ", "Notepad.exe C:\DesktopReadme.txt")

RegWrite("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\explorer\Desktop\NameSpace\"&$CLSID, "", "REG_SZ", $CLSID)

Just a simple example on how to create desktop icons that are like inbox:

They can't be moved into anywhere else but the desktop.

They don't goto recycle bin but instead are gona forever.

They can be shortcuts to other things but without the annoying little arrow icon.

ecetra.

Note: I could demonstrate how to do more things with it if you want, and if I feel like it at the time.

yes these icons on desktop look cool, Herby over at neowin.net has done it but taken it a bit further...

http://www.neowin.net/forum/index.php?show...324&hl=textless

I am finishing up a scriipt that generates the reg files for the textless Icons using a ini file...good learning tool for me.

Edited by wiredbits
Link to comment
Share on other sites

I didn't want to use the Win API way of generating it or the alg because I wanted to make it myself.

;UID Generator by Mixture63

MsgBox(0, "Random UID", GenerateUID())

func GenerateUID()
    $Section1 = Hex(Random(0, 256^2, 1), 4) & Hex(Random(0, 256^2, 1), 4)
    $Section2 = Hex(Random(0, 256^2, 1), 4)
    $Section3 = Hex(Random(0, 256^2, 1), 4)
    $Section4 = Hex(Random(0, 256^2, 1), 4)
    $Section5 = Hex(Random(0, 256^2, 1), 4) & Hex(Random(0, 256^2, 1), 4) & Hex(Random(0, 256^2, 1), 4)
    
    return "{" & $Section1 & "-" & $Section2 & "-" & $Section3 & "-" & $Section4 & "-" & $Section5 & "}"
EndFunc

I had to restrict the size of the random number to 256^2 and the hex length to 4 otherwise the intepeter

has a pissy fit.

Registry explanation comming soon.

Hi

IF you do use your CLSID/GUID with registry you will need to check if CLSID exists before adding... just in case. You also might want to keep track of ones you generate.

Link to comment
Share on other sites

Hi

IF you do use your CLSID/GUID with registry you will need to check if CLSID exists before adding... just in case. You also might want to keep track of ones you generate.

That is not necessary if the UUID is real. If its real, it will be unique across time and space and therefore not conflict with anything. If its a fake UUID, though, all bets are off.
Link to comment
Share on other sites

That is not necessary if the UUID is real. If its real, it will be unique across time and space and therefore not conflict with anything. If its a fake UUID, though, all bets are off.

Yes, that is what i meant my 'your' but you explained it much better...thanks.
Link to comment
Share on other sites

Const $ERROR_SUCCESS = 0
Const $RPC_S_OK = $ERROR_SUCCESS
Const $RPC_S_UUID_LOCAL_ONLY = 1824
Const $RPC_S_UUID_NO_ADDRESS = 1739

;~ typedef struct _GUID {  
;~  unsigned long Data1;  
;~  unsigned short Data2;  
;~  unsigned short Data3;  
;~  unsigned char Data4[8];
;~ } GUID, UUID;
;~ Data1 
;~ Specifies the first 8 hexadecimal digits of the UUID. 
;~ Data2 
;~ Specifies the first group of 4 hexadecimal digits of the UUID. 
;~ Data3 
;~ Specifies the second group of 4 hexadecimal digits of the UUID. 
;~ Data4 
;~ Array of eight elements. The first two elements contain the third group of 4 hexadecimal digits of the UUID.
;~ The remaining six elements contain the final 12 hexadecimal digits of the UUID. 

$_GUID = DllStructCreate("uint;ushort;ushort;ubyte[8]")
If @error Then Exit

;~ RPC_STATUS RPC_ENTRY UuidCreate(
;~   UUID __RPC_FAR* Uuid
;~ );

$ret = DllCall("Rpcrt4.dll","ptr","UuidCreate","ptr",DllStructGetPtr($_GUID))
If Not @error Then
 If $ret[0] = $ERROR_SUCCESS Then
  $uuid = Hex(DllStructGetData($_GUID,1),8) & "-" & _ 
     Hex(DllStructGetData($_GUID,2),4) & "-" & _
     Hex(DllStructGetData($_GUID,3),4) & "-" & _
     Hex(DllStructGetData($_GUID,4,1),2) & Hex(DllStructGetData($_GUID,4,2),2) & "-"
  For $x =3 to 8
   $uuid = $uuid & Hex(DllStructGetData($_GUID,4,$x),2)
  Next
  ConsoleWrite($uuid & @LF)
 EndIf
EndIf
DllStructDelete($_GUID)

Edit: converted to proper uuid

Note:

In Windows NT 4.0, Windows Me/98, and Windows 95 DCOM release, UuidCreate returns RPC_S_UUID_LOCAL_ONLY when the originating computer does not have an ethernet/token ring (IEEE 802.x) address.

In this case, the generated UUID is a valid identifier, and is guaranteed to be unique among all UUIDs generated on the computer.

However, the possibility exists that another computer without an ethernet/token ring address generated the identical UUID.

Therefore you should never use this UUID to identify an object that is not strictly local to your computer.

Computers with ethernet/token ring addresses generate UUIDs that are guaranteed to be globally unique.

Edited by gafrost

SciTE for AutoItDirections for Submitting Standard UDFs

Ā 

Don't argue with an idiot; people watching may not be able to tell the difference.

Ā 

Link to comment
Share on other sites

I haven't done much COM programming recently (thank the gods!) but several years ago there was quite a discussion regarding the globally unique assertion made by the Microsoft SDK COM documentation. One of the items people were pointing to was the ease with which you can actually change your Network MAC address in software.

Microsoft eventually said they don't guarantee global uniqueness its just that the chance of generating a UUID already in use on a particular machine that happens to be running your code is so absurdly small that you can safely consider it to be globally unique.

It was also mentioned that their newer algorithm is not dependent upon the presence of a network adapter for generating strong UUID on Windows 2000 and above systems. On older systems, as stated in the quote below, you still run a higher risk of collision without a network adapter being present.

Note:

In Windows NT 4.0, Windows Me/98, and Windows 95 DCOM release, UuidCreate returns RPC_S_UUID_LOCAL_ONLY when the originating computer does not have an ethernet/token ring (IEEE 802.x) address.

In this case, the generated UUID is a valid identifier, and is guaranteed to be unique among all UUIDs generated on the computer.

However, the possibility exists that another computer without an ethernet/token ring address generated the identical UUID.

Therefore you should never use this UUID to identify an object that is not strictly local to your computer.

Computers with ethernet/token ring addresses generate UUIDs that are guaranteed to be globally unique.

Link to comment
Share on other sites

This is the AutoIT version of bluebearr VB example, where IE is used to copy it to the clipboard.

It now there is an other way in AutoIt to do this.

But it is just out of interest for those who are in COM object programming that I used the example.

Dim $strGUID
Dim $TypeLib
Dim $objIE

$TypeLib = ObjCreate("Scriptlet.TypeLib")
$strGUID = $TypeLib.Guid

MsgBox(0,"Create GUID",$strGUID,5)

$objIE = ObjCreate("InternetExplorer.Application")
$objIE.Navigate("about:blank")
$objIE.document.parentwindow.clipboardData.SetData ("text", $strGUID)
$objIE.Quit()

Might be handy later on.

Link to comment
Share on other sites

If you are still using the release version (as I am), here is how you can generate GUIDs by using the Windows Scripting Host:

#include <File.au3>
#Include <process.au3>

Const $ForReading = 0, $ForAppending = 1, $ForWriting = 2
$strVBScript = 'Set TypeLib = CreateObject("Scriptlet.TypeLib")' & @CRLF _
    & 'Wscript.Echo TypeLib.Guid'
    
$strTempFile1 = _TempFile()
$strTempFile2 = _TempFile()

FileOpen($strTempFile1, $ForWriting)
FileWrite($strTempFile1, $strVBScript)
FileClose($strTempFile1)

_RunDOS("cscript.exe " & $strTempFile1 & " //E:VBSCRIPT //NoLogo> " & $strTempFile2)

FileOpen($strTempFile2, $ForReading)
$GUID = FileReadLine($strTempFile2)
FileClose($strTempFile2)
FileDelete($strTempFile1)
FileDelete($strTempFile2)

ClipPut($GUID)
MsgBox(0, "GUID Generation", "GUID " & @CRLF & @CRLF & "  " & $GUID & @CRLF & @CRLF _
   & "copied to clipboard.")
Edited by bluebearr
BlueBearrOddly enough, this is what I do for fun.
Link to comment
Share on other sites

  • 1 month later...

There's also a good tool from MS Platform SDK: GUIDGen

Usage sample:

Run("C:\Program Files\PSDK\Bin\GuidGen.exe")

$WinTitle = "Create GUID"

If WinWait($WinTitle, "", 30) = 0 Then
    MsgBox (0, "Error", "Could not find window with title " & $WinTitle)
    Exit
EndIf

If Not WinActive ($WinTitle) Then WinActivate($WinTitle)

If WinWaitActive ($WinTitle, "", 30) = 0 Then
    MsgBox (0, "Error", "Could not activate window with title " & $WinTitle)
    Exit
EndIf

Send("4")
Send("!n")
Send("!c")
Send("!x")

$guid = ClipGet()

MsgBox(0, "New GUID", $guid)

UDFS & Apps:

Spoiler

DDEML.au3 - DDE Client + Server
Localization.au3 - localize your scripts
TLI.au3 - type information on COM objects (TLBINF emulation)
TLBAutoEnum.au3 - auto-import of COM constants (enums)
AU3Automation - export AU3 scripts via COM interfaces
TypeLibInspector - OleView was yesterday

Coder's last words before final release: WE APOLOGIZE FOR INCONVENIENCEĀ 

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...