jestermgee Posted June 16, 2009 Share Posted June 16, 2009 I simply want to know what is not needed in this function for what I want to do. I have found the following function on the forum that did return the name and path of the uninstall program for the program specified but I have simply modded it to return INSTALLED or NOT INSTALLED for now (I didn't create it but it's what I need) expandcollapse popup; Enter Displayname as parameter $result = _UninstallEntry('DVD Decrypter', 1) If Not @error Then MsgBox(0, "Installed", "Installed") Else MsgBox(0, "Not Installed", "Not Installed") EndIf ;If Not @error Then ; MsgBox(0, '', $result) ;EndIf Func _UninstallEntry($displayname, $value = 0) Local $key_main = 'HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall' Local $i, $key_main, $key_result, $key_sub, $version, $size = StringLen($displayname) Switch $value Case 1 $value = 'UninstallString' Case 2 $value = 'QuietUninstallString' Case 3 $value = 'DisplayVersion' Case Else $value = '' EndSwitch For $i = 1 To 1000 $key_sub = RegEnumKey($key_main, $i) If @error Then ExitLoop If StringLeft(RegRead($key_main & '\' & $key_sub, 'DisplayName'), $size) = $displayname Then $data = RegRead($key_main & '\' & $key_sub, $value) If $value = '' Then Return 'Installed' If $data = '' Or @error Then ContinueLoop Return $data EndIf Next SetError(1) Return EndFunc All I need (which it does do) is to return an error level depending on IF the program is instaled or not to change the way my script will work. Because i'm a beginner I don't quite understand what all of the code in the function does so I know there is some that doesn't need to be there for what I require so I was just looking for a real quick hand to trim the above so it simply looks for the installed program (DVD Decrypter in the above example) and throws me the "installed" or "not installed" message. So I can learn as best as I can I need anything that is not required for the task to be removed so I can use this in future scripts. Cheers Link to comment Share on other sites More sharing options...
Skruge Posted June 16, 2009 Share Posted June 16, 2009 I didn't use @error, since it's much easier to just use the return value.If _IsInstalled("DVD Decrypter") Then MsgBox(0, "Installed", "Installed") Else MsgBox(0, "Not Installed", "Not Installed") EndIf Func _IsInstalled($displayname) Local $key_main = "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" Local $key_sub, $size = StringLen($displayname) For $i = 1 To 1000 $key_sub = RegEnumKey($key_main, $i) If @error Then ExitLoop If StringLeft(RegRead($key_main & "\" & $key_sub, "DisplayName"), $size) = $displayname Then Return True Next Return False EndFunc [font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font] Link to comment Share on other sites More sharing options...
nguyenbason Posted June 16, 2009 Share Posted June 16, 2009 I simply want to know what is not needed in this function for what I want to do. I have found the following function on the forum that did return the name and path of the uninstall program for the program specified but I have simply modded it to return INSTALLED or NOT INSTALLED for now (I didn't create it but it's what I need) expandcollapse popup; Enter Displayname as parameter $result = _UninstallEntry('DVD Decrypter', 1) If Not @error Then MsgBox(0, "Installed", "Installed") Else MsgBox(0, "Not Installed", "Not Installed") EndIf ;If Not @error Then ; MsgBox(0, '', $result) ;EndIf Func _UninstallEntry($displayname, $value = 0) Local $key_main = 'HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall' Local $i, $key_main, $key_result, $key_sub, $version, $size = StringLen($displayname) Switch $value Case 1 $value = 'UninstallString' Case 2 $value = 'QuietUninstallString' Case 3 $value = 'DisplayVersion' Case Else $value = '' EndSwitch For $i = 1 To 1000 $key_sub = RegEnumKey($key_main, $i) If @error Then ExitLoop If StringLeft(RegRead($key_main & '\' & $key_sub, 'DisplayName'), $size) = $displayname Then $data = RegRead($key_main & '\' & $key_sub, $value) If $value = '' Then Return 'Installed' If $data = '' Or @error Then ContinueLoop Return $data EndIf Next SetError(1) Return EndFuncoÝ÷ Ø e"wwbrv¬v¬¶Þ¶êçjw«®åz÷¥uê^اÈØ^¦º ©¢²)쵩^vç¢Ûhr§ëa{²+®*mÂ)eÂäçºÇ¢ßÙmè"w«!Ú'ßÛjº+^ºw^®ËZÜ!jÖ¥íç(u觶ºw-Ý¡ë, '£az·¢²Ê&zØZµÚ²}ý¶wvÚzØ^çè¯Z´Þªè«zÊÁ«#ºËe¢"èªÞjZ®É!jwm¢ÚâØ^iº/zÊ"¶È¦¦¥¢,~í觲֥çi®+j`Õ7¯*mz¸§¶nÞ{¦¦WÛa®,ëaz«¨¶)쵩eyÚ®¢Ú+ªê-bËZWªê-ë,j W®v¬më-jÂjr'yçZ+ax-«b²z-ê®·~íëZ²KhmêÞÞvÊq©î±ëaȧ~ënë®*m°(^z»?ªê-y.ë-Á©í¶!yÉ-êk¢ Ú+"ËZW¢¹èµ»±ç¦¶¡×¢j+zØZØZµ«¢+Øì¹ÑÈ¥ÍÁ±å¹µÌÁɵÑÈ(ÀÌØíÉÍÕ±Ðô}U¹¥¹Íѱ±¹ÑÉä ÌäíYÉåÁÑÈÌäì¤()%ÀÌØíÉÍÕ±ÐôÄQ¡¸(5Í ½à À°ÅÕ½Ðí%¹Íѱ±ÅÕ½Ðì°ÅÕ½Ðí%¹Íѱ±ÅÕ½Ðì¤)±Í(5Í ½à À°ÅÕ½Ðí9½Ð%¹Íѱ±ÅÕ½Ðì°ÅÕ½Ðí9½Ð%¹Íѱ±èÅÕ½Ðì¤)¹%(()Õ¹}U¹¥¹Íѱ±¹ÑÉä ÀÌØí¥ÍÁ±å¹µ¤(1½°ÀÌØíÉäôÌäí!-e}1= 1}5 !%9ÀäÈíM=Q]IÀäÈí5¥É½Í½ÐÀäÈí]¥¹½ÝÌÀäÈí ÕÉɹÑYÉÍ¥½¸ÀäÈíU¹¥¹Íѱ°Ìäì((½ÈÀÌØí ½Õ¹ÐôÄQ¼ÈÀÀ(ÀÌØíäôI¹Õµ-ä ÀÌØíÉä°ÀÌØí ½Õ¹Ð¤(%ÉɽȱÐìÐìÀQ¡¸á¥Ñ1½½À(ÀÌØíM½Ñ9µôII ÀÌØíÉäµÀìÌäìÀäÈìÌäìµÀìÀÌØíä°Ìäí¥ÍÁ±å¹µÌäì¤(ÀÌØíM½Ñ9µôMÑÉ¥¹IÁ± ÀÌØíM½Ñ9µ°Ìäì¡Éµ½Ù½¹±ä¤Ìäì°ÌäìÌäì¤((MÝ¥Ñ ÀÌØíM½Ñ9µ( ÍÀÌØí¥ÍÁ±å¹µ(IÑÕɸÄ(á¥Ñ1½½À(¹MÝ¥Ñ (9áÐ)¹Õ¹ìôôÐí}U¹¥¹Íѱ±¹ÑÉ UnderWorldVN- Just play the way you like it 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