HELP: Searching for a program... 
Author Message
 HELP: Searching for a program...

I know i can try by reading registry but I can't
find a way to read registry's keys!

HOWTO: Use the Registry API to Save and Retrieve Setting
http://www.*-*-*.com/
NN

Quote:

>How can I search for a program in a user's computer so I can decide if
>he can use my program? I know i can try by reading registry but I can't
>find a way to read registry's keys! Another way is to order computer to
>execute one of the files that the program supports so I can tell me if
>there is or not. For example, if the program is RealPlayer I can run a
>*.RAM or *.RA file . But I can't find a way to do that! I can't find a
>command that I will give a kind of a file and tell me what application
>runs it! Everyone knows how to solve this problem or wants further
>information, let's contact me please...



Thu, 01 Feb 2001 03:00:00 GMT  
 HELP: Searching for a program...
How can I search for a program in a user's computer so I can decide if
he can use my program? I know i can try by reading registry but I can't
find a way to read registry's keys! Another way is to order computer to
execute one of the files that the program supports so I can tell me if
there is or not. For example, if the program is RealPlayer I can run a
*.RAM or *.RA file . But I can't find a way to do that! I can't find a
command that I will give a kind of a file and tell me what application
runs it! Everyone knows how to solve this problem or wants further
information, let's contact me please...


Fri, 02 Feb 2001 03:00:00 GMT  
 HELP: Searching for a program...
[posted to newsgroup & emailed]
On Mon, 17 Aug 1998 00:40:02 +0300, Vladimiros Itsios pondered:

Quote:
> How can I search for a program in a user's computer so I can decide if
> he can use my program? I know i can try by reading registry but I can't
> find a way to read registry's keys! Another way is to order computer to
> execute one of the files that the program supports so I can tell me if
> there is or not. For example, if the program is RealPlayer I can run a
> *.RAM or *.RA file . But I can't find a way to do that! I can't find a
> command that I will give a kind of a file and tell me what application
> runs it! Everyone knows how to solve this problem or wants further
> information, let's contact me please...

Here's some code of mine that should do the trick, if I've copied everything
properly. It's a modified version of some code I downloaded somewhere, and
turned into an easy-to-use Sub.

First, stick these in the Declarations section of a module (watch out for the
word wrapping):

Declare Function RegCreateKey& Lib "advapi32.DLL" Alias "RegCreateKeyA" (ByVal
hKey&, ByVal lpszSubKey$, lphKey&)
Declare Function RegSetValue& Lib "advapi32.DLL" Alias "RegSetValueA" (ByVal
hKey&, ByVal lpszSubKey$, ByVal fdwType&, ByVal lpszValue$, ByVal dwLength&)

' Return codes from Registration functions.
Public Const ERROR_SUCCESS = 0&
Public Const ERROR_BADDB = 1&
Public Const ERROR_BADKEY = 2&
Public Const ERROR_CANTOPEN = 3&
Public Const ERROR_CANTREAD = 4&

Public Const ERROR_CANTWRITE = 5&
Public Const ERROR_OUTOFMEMORY = 6&
Public Const ERROR_INVALID_PARAMETER = 7&
Public Const ERROR_ACCESS_DENIED = 8&

Public Const HKEY_CLASSES_ROOT = &H80000000
Public Const MAX_PATH = 256&
Public Const REG_SZ = 1

Then, add this sub, and modify to taste with the application name, EXE filename,
and optional icon. If no icon is specified, a default icon is used which is a
small version of the app's icon on a sheet of paper.

Sub AssociateFileType(extension As String, description As String)
Dim sKeyName As String   'Holds Key Name in registry.
Dim sKeyValue As String  'Holds Key Value in registry.
Dim ret&                 'Holds error status if any from API calls.

Dim lphKey&              'Holds created key handle from RegCreateKey.

k$ = "AppName"        ' INSERT UNIQUE APPLICATION NAME HERE!

sKeyName = k$
sKeyValue = description
ret& = RegCreateKey&(HKEY_CLASSES_ROOT, sKeyName, lphKey&)
ret& = RegSetValue&(lphKey&, "", REG_SZ, sKeyValue, 0&)

sKeyName = extension
sKeyValue = k$
ret& = RegCreateKey&(HKEY_CLASSES_ROOT, sKeyName, lphKey&)

ret& = RegSetValue&(lphKey&, "", REG_SZ, sKeyValue, 0&)

sKeyName = k$
sKeyValue = App.Path + "\app.exe %1"  ' INSERT EXE FILENAME & PATH HERE!
ret& = RegCreateKey&(HKEY_CLASSES_ROOT, sKeyName, lphKey&)
ret& = RegSetValue&(lphKey&, "shell\open\command", REG_SZ, sKeyValue, MAX_PATH)

' Associate icon  *** optional, remove if desired ***:
sKeyName = k$
sKeyValue = App.Path + "\icon.ico,0"  ' INSERT ICON FILENAME & PATH HERE!
ret& = RegCreateKey&(HKEY_CLASSES_ROOT, sKeyName, lphKey&)
ret& = RegSetValue&(lphKey&, "DefaultIcon", REG_SZ, sKeyValue, MAX_PATH)

End Sub

Then, call it when your app starts, or in its setup routines.

eg.
AssociateFileType("txt", "Text File")

You'll now want to get your app to check its command line when it starts. If
called normally, Command will be a zero-length string (""). If not, Command will
contain the path & filename to load.

Hope this helps!

Alex Warren

http://come.to/axe           - Axe Software: freeware for DOS & Windows
http://come.to/basixfanzine  - Basix Fanzine: magazine for BASIC programmers
http://members.tripod.com/~perditionproductions           - mods (IT format)
-----------------------------------------------------------------------------
(please reply to the newsgroup - if you must reply by email, change the anti-
spam rubbish to the email address above)



Sat, 03 Feb 2001 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. 'Help-Find'-style interface for vb4 programmed database search

2. Searching help for VB-database programming

3. 'Help-Find'-style interface for vb4 programmed database search

4. Searching help for VB-database programming

5. Searching help for VB-database programming

6. How to program a search contact funtion with listening

7. Searching for a quickly programming visual language

8. Wildcard input for text searching program

9. Directry search/DB programming

10. Database Search and Display Program

11. Making, Mp3 search program like limewire or kazaa

12. I search Icon Collection for my programs ????

 

 
Powered by phpBB® Forum Software