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 28 of 28

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
    74

    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 jdc2000's Avatar
    Join Date
    Oct 2001
    Location
    Idaho Falls, Idaho USA
    Posts
    1,306

    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
    74

    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
    74

    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 jdc2000's Avatar
    Join Date
    Oct 2001
    Location
    Idaho Falls, Idaho USA
    Posts
    1,306

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


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

    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: 168
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
    74

    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
    74

    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: 168
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
    5,299

    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
    74

    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?

  17. #17
    Lively Member
    Join Date
    Mar 2009
    Posts
    74

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

    I did some debugging and found out that when my program does a Dir(<path>) function call, if the <Path> contains a PDF file, e.g., "Z:\Docs\MyDoc.pdf", it takes so very long (up to an hour!) before it returns. This is why it's taking very long to open a PDF - just the attempt to locate the file already takes so long. This only happens with PDF but not with TIF or JPG files. Why!? Very strange!

    Does this give you any clue as to what my real problem is and whether this problem could be fixed with shims and what shims to use?

    Thanks!

  18. #18
    Frenzied Member jdc2000's Avatar
    Join Date
    Oct 2001
    Location
    Idaho Falls, Idaho USA
    Posts
    1,306

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

    If you open a Command Prompt window (cmd) and do a 'dir Z:\PathName\*.pdf', what happens? Does it take a long time?

    Note:
    Microsoft's latest update to Windows 10 messed up mapped drives. If Z: is a network mapped drive, that might explain it. Try the same thing on a C:\PathName\*.pdf to see what happens. Also, try replacing the Z:\PathName with \\ComputerName\Pathname to see if this helps.

  19. #19
    Lively Member
    Join Date
    Mar 2009
    Posts
    74

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

    Quote Originally Posted by jdc2000 View Post
    If you open a Command Prompt window (cmd) and do a 'dir Z:\PathName\*.pdf', what happens? Does it take a long time?

    Note:
    Microsoft's latest update to Windows 10 messed up mapped drives. If Z: is a network mapped drive, that might explain it. Try the same thing on a C:\PathName\*.pdf to see what happens. Also, try replacing the Z:\PathName with \\ComputerName\Pathname to see if this helps.
    Yes, Z: is a network mapped drive.

    I tried on the command prompt 'dir Z:\Docs\MyDoc.pdf' and it takes a very long time. BTW the folder Z:\Docs has almost 700,000 files in it. Thinking that maybe the slowness is due to the folder having so many files, I tried the same command from a Windows 7 machine and found that it's very fast - less than 1 second.

    Next I tried 'dir Z:\Temp\MyTemp.pdf' in the Windows 10 machine and it finished immediately, but the folder Z:\Temp has only 25 files in it. So it seems that Windows 10 is very slow when accessing a folder with so many files. The Windows 10 machine has 64-bit OS and only 4 GB RAM installed. Could this be the reason for the slowness? Does it need more RAM?

    I also tried the above commands with \\ComputerName\PathName replacing Z:\PathName and it's also very slow.

  20. #20
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    3,369

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

    700.000 files in a single directory?
    Why not try to organize the files in a multiple folder structure?

  21. #21
    Lively Member
    Join Date
    Mar 2009
    Posts
    74

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

    Quote Originally Posted by Arnoutdv View Post
    700.000 files in a single directory?
    Why not try to organize the files in a multiple folder structure?
    Yes I know. That will be a future revision of the program. The revision will take time because there are so many processes that will be affected down the line.

  22. #22
    Frenzied Member jdc2000's Avatar
    Join Date
    Oct 2001
    Location
    Idaho Falls, Idaho USA
    Posts
    1,306

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

    700,000 files in a directory is too many files if you want any decent speed, especially over a network.

    Is the Windows Indexing service used on the client and/or the network computers?
    Last edited by jdc2000; Nov 27th, 2018 at 06:32 PM.

  23. #23
    Lively Member
    Join Date
    Mar 2009
    Posts
    74

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

    Quote Originally Posted by jdc2000 View Post
    700,000 files in a directory is too many files if you want any decent speed, especially over a network.

    Is the Windows Indexing service used on the client and/or the network computers?
    I'm not sure if the indexing service is used. But regardless, why is it very slow on Windows 10 and very fast on Windows 7 is my big question.

  24. #24
    Fanatic Member
    Join Date
    Nov 2017
    Posts
    682

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

    Quote Originally Posted by mtl777 View Post
    I'm not sure if the indexing service is used. But regardless, why is it very slow on Windows 10 and very fast on Windows 7 is my big question.
    ...and jdc2000's question is exactly the type of thing you should be looking at to differentiate why the big difference is there.

    Another thing, it could be that, assuming there is Antivirus present on both devices, that the Windows 7 device is set to not scan files on network shares/drives, but the Windows 10 device is set to scan then. Or it could be some other obscure functionality that Windows 10 has that Windows 7 doesn't. Or it could be that, if those 700000 files are all pdf files, that some PDF related software on the Windows 10 machine is running that automatically tries to gather metadata or something from every PDF file it encounters in order to be "helpful", and that is bogging down the system.

    Things to check during the wait:
    Task Manager - what process (if any) is pegging the CPU
    Run Process Monitor - Download it directly from Microsoft - If you've never run this before it can be a bit overwhelming because when you run it it will show you the many, many, many thousands of I/O and other events that happen behind the scenes every second, but it might help pinpoint what is happening in the background. You'll want to get a good grasp on how the filtering works so that you can eliminate a lot of the noise.

    All that being said, it would probably be in your best interest to do something to divvy up the files into subfolders sooner rather than later. I've seen Windows systems choke on much fewer than 700000 files in a single folder.

  25. #25
    Frenzied Member jdc2000's Avatar
    Join Date
    Oct 2001
    Location
    Idaho Falls, Idaho USA
    Posts
    1,306

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

    OptionBase1 has the right idea. Something on the Windows 10 system is probably trying to be "helpful", but is causing massive delays on a folder with 700,000 files. Note that on Windows 10, the default .pdf reader is Microsoft Edge. Who knows what that might be doing to your scans for .pdf files.

  26. #26
    Lively Member
    Join Date
    Mar 2009
    Posts
    74

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

    I have finally found the solution to my problem! It turns out there's a bug in Windows 10 after update 1803 is installed:

    https://social.technet.microsoft.com...tpronetworking

    So the solution is simply to add the following to the registry of the machine that is experiencing the problem:

    HKLM\SYSTEM\CurrentControlSet\Services\LanmanWorkstation\Parameters

    Add:

    DirectoryCacheLifetime Dword=0
    FileInfoCacheLifetime Dword=0
    FileNotFoundCacheLifetime Dword=0


    Then reboot the machine.

    Viola, instant access - even if the folder now contains close to a million files!

    I hope this solution helps another person who has this problem!

  27. #27
    Frenzied Member jdc2000's Avatar
    Join Date
    Oct 2001
    Location
    Idaho Falls, Idaho USA
    Posts
    1,306

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

    Thanks for the update!

  28. #28
    Frenzied Member
    Join Date
    Mar 2008
    Posts
    1,139

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

    I don't see the FindExecutable API mentioned in the posts above, it may be worth a look at too.

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