Rabu, 21 September 2016

Re: [MS_AccessPros] GetSetting


John ... 

Thanks for the information. 

I thought the GetSetting function as I understood it was going to be a great tool, but unfortunately I didn't read the part about the data that one looks for must be under the HKEY_LOCAL_USER registry key.
In my case, the data I am looking for is under the HKEY_LOCAL_MACHINE.

I am aware of the Windows API, but that solution seems overkill in my situation.

I have a workaround for now using the DIR function shown below
Sub IrfanVersion()

Dim MyFolderFileName As String
    If Dir("C:\Program Files\IrfanView\I_view32.exe") = "I_view32.exe" Then
        MyFolderFileName = "C:\Program Files\I_view32.exe"
    ElseIf Dir("C:\Program Files\I_view64.exe") = "I_view64.exe" Then
        MyFolderFileName = "C:\Program Files\I_view64.exe"
    ElseIf Dir("C:\Program Files(x86)\I_view32.exe") = "I_view32.exe" Then
        MyFolderFileName = "C:\Program Files(x86)\I_view32.exe"
    End If

End Sub

Thanks again for the info, I would have spent a lot of time trying to get GetSetting to work. 
It's sure great to be able to ask 'the experts'


---In MS_Access_Professionals@yahoogroups.com, <JohnV@...> wrote :
I found this about the GetSetting function:

If any of the items named in the GetSetting arguments do not exist, GetSetting returns a value of Default.
Because it operates under the HKEY_LOCAL_USER registry key, which is not active until a user logs on interactively, GetSettingrequires that a user be logged on.
Registry settings that are to be accessed from a non-interactive process (such as Mtx.exe) should be stored under either the HKEY_LOCAL_MACHINE\Software\ or the HKEY_USER\DEFAULT\Software registry keys.
So, if the key you're requesting isn't in HKEY_LOCAL_USER, you won't find it.

You could try using the Windows API to read the value.  You can find info about how to do it in VBA here:

John Viescas, Author
Effective SQL
SQL Queries for Mere Mortals 
Microsoft Access 2010 Inside Out
Microsoft Access 2007 Inside Out
Microsoft Access 2003 Inside Out
Building Microsoft Access Applications 
(Paris, France)

On Sep 20, 2016, at 5:09 AM, patrinod <no_reply@yahoogroups.com> wrote:

I have an Access application where I shell out to Irfanview which worked quite well until encountering someone who had the 64 bit version installed.

Irfanview uses the file name I_view32.exe for the 32 bit version and I_view64.exe for the 64 bit version.

I thought I could use "GetSetting" to look in the registry to get the path and executable file name.

In the registry, under Irfanview there is a key shell with a subkey open and a subkey command.

The data value under the subkey command contains the path and file name.

I've tried using Msgbox getsetting("irfanview","open", "command") and variations.

I've guess I don't understand the section and key parameters I need to get this to work Has anyone used the getsetting function successfully and can help out or is there a better way to get the path and file name for a program?




Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (3)

Have you tried the highest rated email app?
With 4.5 stars in iTunes, the Yahoo Mail app is the highest rated email app on the market. What are you waiting for? Now you can access all your inboxes (Gmail, Outlook, AOL and more) in one place. Never delete an email again with 1000GB of free cloud storage.



Tidak ada komentar:

Posting Komentar