cppman Posted April 9, 2006 Share Posted April 9, 2006 (edited) Here is a really pretty simple UDF i wrote.It returns the default aplication for a file extension.The Return Value is the Full Path to the File.Filename: 'extension.au3'expandcollapse popup;================================== ; Function Name: _ReturnDefaultApp($extension) ; Description: Returns the location to the default application that is used for the specified extension. ; Parameter(s): $extension - Extension that you would like to use: Must contain the period. (e.g.: '.txt'). ; Requirement(s): AutoIt3 Beta. ; Return Value(s): On Success - Returns full location to the executable. ; On Failure - 0 ; Author(s): chris95219 ;================================== Func _ReturnDefaultApp($extension) $RegLocation = RegRead("HKEY_CLASSES_ROOT\" & $extension, "") $RegLoc = RegRead("HKEY_CLASSES_ROOT\" & $RegLocation & "\Shell\Open\command", "") $LocationA = _RemoveFromString($RegLoc, "%") $LocationB = _RemoveFromString($LocationA, Chr(34)) $LocationC = _RemoveFromString($LocationB, ",") $FullLocation = _Convert($LocationC) if $FullLocation = "" Then Return 0 EndIf Return $FullLocation EndFunc Func _RemoveFromString($String, $Char) $Array = StringSplit($String, "") Local $ComString For $i = 1 to $Array[0] If $Array[$i] == $Char Then $Array[$i] = "" EndIf $ComString &= $Array[$i] Next Return $ComString EndFunc Func _Convert($string) local $ComString $ComString = StringReplace($string, "SystemRoot", @WindowsDir, 1) $ComString = StringReplace($ComString, "rundll32.exe ", "") $ComString = StringReplace($ComString, "ImageView_FullScreen", "") $ComString = StringReplace($ComString, " 1", "") $ComString = StringReplace($ComString, " /prefetch:6 /Open L", "") $ComString = StringReplace($ComString, " -url", "") Return $ComString Return EndFuncusage#include "extension.au3" $ext = InputBox("Extension", "What is the Extension?") MsgBox(0, "Extension Information:", "The default application for that extension is: " & @CRLF & _ReturnDefaultApp($ext))This can be used if your not sure what the default application for a file is and need to run a file.here is another example:#include "extension.au3" Run(_ReturnDefaultApp(".html") & " http://www.google.com")This should open www.google.com in your DEFAULT browser. Edited April 9, 2006 by CHRIS95219 Miva OS Project Link to comment Share on other sites More sharing options...
Amen Posted April 9, 2006 Share Posted April 9, 2006 (edited) Works Great and i think it's very usefull Function.Thanx for sharing! Edited April 9, 2006 by Amen Plugged ThoughtsQBsick? check my Old staff (New Launchers to Work with Windows.Thnx to Autoit!)Game Development ToolsPortes (A Backgammon game)Ball (An Arkanoid Style game)Au3? SecretProgz - Reveals Commands that can be used on your system CleanOut - Uninstall leftovers Enable windows XP Autologon. Stop Windows Auto Sharing your hard drives (C$,D$,etc) D-Link - Create a dynamic link.Useful for server shortcuts Fun - How would your name sounds in Japanese,Russian or Reventian? Fix_srt - Shift a subtitle (.srt) some secs +/- Link to comment Share on other sites More sharing options...
cppman Posted April 9, 2006 Author Share Posted April 9, 2006 Thanks . Glad you like it! Miva OS Project Link to comment Share on other sites More sharing options...
RazerM Posted April 9, 2006 Share Posted April 9, 2006 the browser function looks good. Well done My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop. Link to comment Share on other sites More sharing options...
cppman Posted April 10, 2006 Author Share Posted April 10, 2006 Thanks! Miva OS Project Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now