PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
[RESOLVED] Path to Acrobat Reader from Registry?-VBForums
Results 1 to 16 of 16

Thread: [RESOLVED] Path to Acrobat Reader from Registry?

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2003
    Location
    Cape Town
    Posts
    5

    Resolved [RESOLVED] Path to Acrobat Reader from Registry?

    Hi

    I want to launch a PDF from my app but for that need to get the path to the Acrobat reader (AcroRd32.exe) from the registry.

    How would i do that?

    Thanks

    Hagen

  2. #2
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,135

    Re: Path to Acrobat Reader from Registry?

    You can use ShellExecute to launch pdf file with default program:
    VB Code:
    1. Option Explicit
    2.  
    3. Private Declare Function ShellExecuteAny Lib "shell32.dll" Alias "ShellExecuteA" _
    4.    (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, _
    5.    ByVal lpParameters As Any, ByVal lpDirectory As Any, ByVal nShowCmd As Long) As Long
    6.  
    7. Private Sub Command1_Click()
    8.     ShellExecuteAny Me.hwnd, "open", "C:\test.pdf", ByVal 0&, ByVal 0&, vbNormalFocus
    9. End Sub

  3. #3
    Giants World Champs!!!! Mark Gambo's Avatar
    Join Date
    Sep 2003
    Location
    Colorado
    Posts
    2,965

    Re: Path to Acrobat Reader from Registry?

    Try HKEY_CLASSES_ROOT --> acrobat --> DefaultIcon
    OR
    HKEY_CLASSES_ROOT --> AcroExch.Document --> Shell --> Open --> Command
    Regards,

    Mark

    Please remember to rate posts! Rate any post you find helpful. Use the link to the left - "Rate this Post". Please use [highlight='vb'] your code goes in here [/highlight] tags when posting code. When a question you asked has been resolved, please go to the top of the original post and click "Thread Tools" then select "Mark Thread Resolved."


  4. #4
    Giants World Champs!!!! Mark Gambo's Avatar
    Join Date
    Sep 2003
    Location
    Colorado
    Posts
    2,965

    Re: Path to Acrobat Reader from Registry?

    Or

    HKEY_CLASSES_ROOT --> AcroExch.Document.7 --> shell --> Open --> command
    Regards,

    Mark

    Please remember to rate posts! Rate any post you find helpful. Use the link to the left - "Rate this Post". Please use [highlight='vb'] your code goes in here [/highlight] tags when posting code. When a question you asked has been resolved, please go to the top of the original post and click "Thread Tools" then select "Mark Thread Resolved."


  5. #5

    Thread Starter
    New Member
    Join Date
    Jun 2003
    Location
    Cape Town
    Posts
    5

    Re: Path to Acrobat Reader from Registry?

    Thanks for your help. This works well.

    Quote Originally Posted by RhinoBull
    You can use ShellExecute to launch pdf file with default program:
    VB Code:
    1. Option Explicit
    2.  
    3. Private Declare Function ShellExecuteAny Lib "shell32.dll" Alias "ShellExecuteA" _
    4.    (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, _
    5.    ByVal lpParameters As Any, ByVal lpDirectory As Any, ByVal nShowCmd As Long) As Long
    6.  
    7. Private Sub Command1_Click()
    8.     ShellExecuteAny Me.hwnd, "open", "C:\test.pdf", ByVal 0&, ByVal 0&, vbNormalFocus
    9. End Sub

  6. #6
    Lively Member
    Join Date
    Mar 2009
    Posts
    69

    Re: Path to Acrobat Reader from Registry?

    Quote Originally Posted by RhinoBull View Post
    You can use ShellExecute to launch pdf file with default program:
    VB Code:
    1. Option Explicit
    2.  
    3. Private Declare Function ShellExecuteAny Lib "shell32.dll" Alias "ShellExecuteA" _
    4.    (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, _
    5.    ByVal lpParameters As Any, ByVal lpDirectory As Any, ByVal nShowCmd As Long) As Long
    6.  
    7. Private Sub Command1_Click()
    8.     ShellExecuteAny Me.hwnd, "open", "C:\test.pdf", ByVal 0&, ByVal 0&, vbNormalFocus
    9. End Sub
    I'm using code like this to open PDF files. It works with Windows 7 and XP but now it doesn't work anymore with Windows 10. Could someone please post a version of this code for Windows 10?

  7. #7
    Frenzied Member
    Join Date
    Oct 2001
    Location
    Idaho Falls, Idaho USA
    Posts
    1,192

    Re: [RESOLVED] Path to Acrobat Reader from Registry?

    What happens when you try it in Windows 10?

    Note that the default .pdf reader in Windows 10 is Microsoft Edge.

  8. #8
    Lively Member
    Join Date
    Mar 2009
    Posts
    69

    Re: [RESOLVED] Path to Acrobat Reader from Registry?

    Quote Originally Posted by jdc2000 View Post
    What happens when you try it in Windows 10?

    Note that the default .pdf reader in Windows 10 is Microsoft Edge.
    Nothing but an hourglass which goes on and on for maybe 7 minutes and then the application crashes.

  9. #9
    Lively Member
    Join Date
    Mar 2009
    Posts
    69

    Re: [RESOLVED] Path to Acrobat Reader from Registry?

    Quote Originally Posted by jdc2000 View Post
    What happens when you try it in Windows 10?

    Note that the default .pdf reader in Windows 10 is Microsoft Edge.
    On further testing, I found out that sometimes, after 30 minutes of the hourglass spinning, it finally displays the PDF. But this is of course unacceptable for the user!

    Is this probably an issue with the Shell32.dll being used in Windows 10?

    I wish someone could help me fix this problem.

  10. #10
    Frenzied Member
    Join Date
    Oct 2001
    Location
    Idaho Falls, Idaho USA
    Posts
    1,192

    Re: [RESOLVED] Path to Acrobat Reader from Registry?


  11. #11
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    4,677

    Re: [RESOLVED] Path to Acrobat Reader from Registry?

    I can tell you about some problems I had with ShellExecute and Windows 10 (and even slightly earlier versions of Windows).

    I'm not totally clear about what's happening, but I know for a fact that almost all of the compatibility settings (i.e., groups of shims) tamper with the way ShellExecute works. When I first started using later versions of Windows, I'd set the IDE to use one of those compatibility settings, and was having constant problems with ShellExecute. It took me a while to put the two together. Why I ultimately did was because I wasn't having any problems with compiled executables. I haven't found a reason to use any compatibility settings on a compiled executable for any version of Windows.

    But, I wanted to get the IDE (when running p-code) working as well. I started playing around with the shims, and found the answer. The VB6 IDE only needs a minimum of shims to work correctly. Here's a link that talks about those shims.

    And here's a picture of the shims I have installed for the VB6 IDE (and no compatibility settings on the properties window). With those settings, all works perfectly with respect to ShellExecute. You will have to install the Application Compatibility Toolkit to fix this, which is a bit of a learning curve. There's a link somewhere where you can download that from the Microsoft website, but I'll let you sort that out. I'm confident that this is what it's going to take to fix things though.

    Name:  Compat.png
Views: 46
Size:  10.9 KB

    Good Luck,
    Elroy

    EDIT1: As a note, I shell out to PDF files all the time in my primary application.
    Any software I post in these forums written by me is provided “AS IS” without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. Please understand that I’ve been programming since the mid-1970s and still have some of that code. My contemporary VB6 project is approaching 1,000 modules. In addition, I have a “VB6 random code folder” that is overflowing. I’ve been at this long enough to truly not know with absolute certainty from whence every single line of my code has come, with much of it coming from programmers under my employ who signed intellectual property transfers. I have not deliberately attempted to remove any licenses and/or attributions from any software. If someone finds that I have inadvertently done so, I sincerely apologize, and, upon notice and reasonable proof, will re-attach those licenses and/or attributions. To all, peace and happiness.

  12. #12
    Lively Member
    Join Date
    Mar 2009
    Posts
    69

    Re: [RESOLVED] Path to Acrobat Reader from Registry?

    Quote Originally Posted by jdc2000 View Post
    Thank you so much! I'll look into this.

  13. #13
    Lively Member
    Join Date
    Mar 2009
    Posts
    69

    Re: [RESOLVED] Path to Acrobat Reader from Registry?

    Quote Originally Posted by Elroy View Post
    I can tell you about some problems I had with ShellExecute and Windows 10 (and even slightly earlier versions of Windows).

    I'm not totally clear about what's happening, but I know for a fact that almost all of the compatibility settings (i.e., groups of shims) tamper with the way ShellExecute works. When I first started using later versions of Windows, I'd set the IDE to use one of those compatibility settings, and was having constant problems with ShellExecute. It took me a while to put the two together. Why I ultimately did was because I wasn't having any problems with compiled executables. I haven't found a reason to use any compatibility settings on a compiled executable for any version of Windows.

    But, I wanted to get the IDE (when running p-code) working as well. I started playing around with the shims, and found the answer. The VB6 IDE only needs a minimum of shims to work correctly. Here's a link that talks about those shims.

    And here's a picture of the shims I have installed for the VB6 IDE (and no compatibility settings on the properties window). With those settings, all works perfectly with respect to ShellExecute. You will have to install the Application Compatibility Toolkit to fix this, which is a bit of a learning curve. There's a link somewhere where you can download that from the Microsoft website, but I'll let you sort that out. I'm confident that this is what it's going to take to fix things though.

    Name:  Compat.png
Views: 46
Size:  10.9 KB

    Good Luck,
    Elroy

    EDIT1: As a note, I shell out to PDF files all the time in my primary application.

    Thank you so much!

    Sorry for my ignorance but what exactly are shims?

    So this fixed your problem with the IDE but you didn't have any problem with compiled executables? My problem is with my compiled executable though. Will this also fix my problem?

  14. #14
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    4,677

    Re: [RESOLVED] Path to Acrobat Reader from Registry?

    Quote Originally Posted by mtl777 View Post
    Sorry for my ignorance but what exactly are shims?

    So this fixed your problem with the IDE but you didn't have any problem with compiled executables? My problem is with my compiled executable though. Will this also fix my problem?
    Hi mtl777,

    A shim is a small bit of machine code that gets placed between your program and the Windows API calls (whether you've called the API function or whether it's something down in the VB6 library that called the API function). There are 100s (if not 1000s) of shims you can use for Windows 10 to make older programs work correctly.

    Here's the Wikipedia page, and here's a really good page from Microsoft about shims.

    Basically, all the options on the properties Compatibility tab are "groups of shims", particularly the Compatibility Mode options. However, with respect to both the VB6 IDE and any compiled VB6 program, those "groups of shims" are too far reaching, causing more problems than they solve.

    With the way you described the problem, I sort of assumed that you're setting a Compatibility Setting on your compiled VB6 program, because that's where I've seen the problem created. It's been my experience that, if I don't set any Compatibility Settings on these compiled programs, that ShellExecute works perfectly, including shelling to PDF files. However, if/when I use these Compatibility Settings, I start having problems just as you describe.

    If you're having problems with a compiled program, and you're certain that no Compatibility Settings are set, then I'm at a loss.

    Good Luck,
    Elroy
    Any software I post in these forums written by me is provided “AS IS” without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. Please understand that I’ve been programming since the mid-1970s and still have some of that code. My contemporary VB6 project is approaching 1,000 modules. In addition, I have a “VB6 random code folder” that is overflowing. I’ve been at this long enough to truly not know with absolute certainty from whence every single line of my code has come, with much of it coming from programmers under my employ who signed intellectual property transfers. I have not deliberately attempted to remove any licenses and/or attributions from any software. If someone finds that I have inadvertently done so, I sincerely apologize, and, upon notice and reasonable proof, will re-attach those licenses and/or attributions. To all, peace and happiness.

  15. #15

  16. #16
    Lively Member
    Join Date
    Mar 2009
    Posts
    69

    Re: [RESOLVED] Path to Acrobat Reader from Registry?

    Hey guys, thank you so much for the good education on shims! Much appreciated.

    In my case, the app is saved in the users' local drive and runs from there. Does it mean that I have to install the ACT in each user's machine and configure the app on each one? Also, I didn't make any compatibility settings for the app so I wonder what's causing it to not work with Windows 10.

    What's going to be tough is how to find out what are the things that are causing the incompatibility so that I can determine what shims I should use to fix the incompatibility. Any ideas on how to go about this?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width