News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

Exploring COM

Started by sinsi, December 20, 2019, 02:18:26 AM

Previous topic - Next topic

sinsi

Hi Biterider, can you tell me the pdf viewer you are using (Adobe,Sumatra etc)? And any info on the crash?
Cheers.

jj2007

#16
Quote from: sinsi on December 21, 2019, 10:33:12 PM
Quote from: jj2007 on December 21, 2019, 09:27:47 PM
That is ERROR_NO_ASSOCIATION. But GetLastError says everything is ok, and a double-click on the word doc opens it in Word - mysteries of Windows :biggrin:
Does Explorer preview the doc?

No. Attached Further down a version that takes the file from the commandline and does error checks, plus some testfiles. *.txt and *.html work flawlessly, *.pdf opens but hangs, the rest doesn't work at all :sad:


Biterider

Hi Sinsi
The ProgID is found in the registry under PDFPrevHndlr.PDFPreviewHandler (StdKey = Adobe PDF Preview Handler for Vista).
The Subkey CLSID is {DC6EFB56-9CFA-464D-8880-44885D7DC193}, which is the StdKey in HKEY_CLASSES_ROOT\.pdf\ShellEx\

Finally \HKEY_CLASSES_ROOT\Wow6432Node\CLSID\{DC6EFB56-9CFA-464D-8880-44885D7DC193} points to an entry holding an AppID = {534A1E02-D58F-44f0-B58B-36CBED287C7C} and a DisplayName = @C:\Program Files (x86)\Adobe\Acrobat Reader DC\Reader\pdfprevhndlr.dll,-101.
Computer\HKEY_CLASSES_ROOT\AppID\{534A1E02-D58F-44f0-B58B-36CBED287C7C} has a key called DllSurrogate containig the following path C:\Windows\SysWOW64\prevhost.exe

So, if I'm not wrong, the answer is "Acrobat Reader DC".

About the crash, what I see is the window with a bray background and then it stops running when DoPreview returns with an error code.

Biterider


Biterider

Hi Sinsi
A third try with a .txt file works OK like the .docx file.

Biterider




sinsi

One thing I have noticed about a pdf is that nothing shows until you click the scroll bar, maybe this would make you think that it has crashed?

jj, is this right?

filename        $$eax           Z:\jj\preview\Test.jpg......T.e.s.t...j.p.g..
extension       $$eax           j\preview\Test.jpg......s.t...j.p.g..
AssocQueryString        $$sExt$         j\preview\Test.jpg......s.t...j.p.g..
AssocQueryString        x:eax           80070483

extension doesn't look right, surely should be .jpg ?

jj2007

Oops, you are right about the extension - my fault :thumbsup:

Quote from: sinsi on December 22, 2019, 12:48:07 AM
One thing I have noticed about a pdf is that nothing shows until you click the scroll bar

No such thing here, the pdf shows immediately (and hangs).
*.txt, *.html, *.rtf work fine here. Same for most text formats like *.inc, *.rc but not *.asm. No luck with *.jpg or *.png :sad:

Biterider

Hi sinsi
I finally debugged the code using devenv.exe /DebugExe previewer.exe

The line
covoke  pph,IPreviewHandler,DoPreview
returns an error code (80004005) and

test    eax,eax
jnz       done

finalizes the application jumping to done:
The line
INVOKE  SafeRelease,pph
takes more than 4 seconds to execute. That's why I thought it crashes, but no, it executes fine up to the end.

Biterider

sinsi

OK, another attempt. This one previews everything I try (that can be previewed), even music files.
Apparently Microsoft stopped using preview handlers for images after XP?

Still having winword.exe remaining and pdfs not showing until a scroll bar click.
Excel behaves itself though.

The error code 80004005 is a generic failure E_FAIL, so who knows what that is :rolleyes:

Next step after some sleep (it's 2am) is to add some debug feedback and maybe install Adobe (yuck).

Thanks for your efforts fellas  :thumbsup:


EDIT: forgot to add that the program takes a file from the command line and will try to use a shell item if the file/stream interface isn't there.

Biterider

Hi
Testing docx, xlsx, pptx, all succeed presenting the preview.
There are very few file extensions that have a ShellEx\{8895B1C6-B41F-4C1C-A562-0D564250836F} key.
On my system, .png or .jpg don't have one. Previewing on the explorer must take another way.

Biterider

jimg

Slightly off topic, but what does one have to install to get the include files under folder

C:\Program Files (x86)\Windows Kits\10\

I don't have bin or lib folders here.

jj2007

Quote from: Biterider on December 22, 2019, 01:36:42 AMThe line
covoke  pph,IPreviewHandler,DoPreview
returns an error code (80004005)

Not on my machine. Here, it either exits after AssocQueryString, or it succeeds - see the DoPrev line.

filename                $$eax           C:\Masm32\MasmBasic\Members\Sinsi\previewer.inc
extension               $$eax           .inc
AssocQueryString        x:eax           00000000
CLSIDFromString         x:eax           00000000
CoCreateInstance        x:eax           00000000
TryUsingStream          $$filename$     C:\Masm32\MasmBasic\Members\Sinsi\previewer.inc
TryUsingStream          x:eax           00000000
IPreviewHandler SetWin  x:eax           00000000
IPreviewHandler DoPrev  x:eax           00000000
IPreviewHandler Unload  x:eax           00000000

*** if it hangs, press Ctrl C ***
SafeRelease pst         x:eax           00000000
SafeRelease pif         x:eax           00000001
SafeRelease pph         x:eax           00000000
CoUninitialize          x:eax           00000000

Biterider

Hi jimg
QuoteSlightly off topic, but what does one have to install to get the include files under folder
C:\Program Files (x86)\Windows Kits\10\
I don't have bin or lib folders here.
You can install the latest MS SDK for Windows from here https://developer.microsoft.com/de-de/windows/downloads/windows-10-sdk
You will get the most important binaries. Include files for MASM are not there. You can get it from the MASM32 package or other translations here in the forum.
The ObjAsm package also offers a good set of translated include files (check the h2incx project).

@sinsi: were did you get the SDK release 10.0.19018.0?

Biterider

sinsi

Quote from: Biterider on December 22, 2019, 08:31:43 AM
@sinsi: were did you get the SDK release 10.0.19018.0?

I think 19018 was a Windows Insider preview version.

Latest news
Download link, 740MB - not sure if you need to be an Insider


Biterider

Hi
QuoteAnd knowing the terminology - why is it called an apartment???
Maybe this post of Raymond Chen can clarify it  :icon_idea:
https://devblogs.microsoft.com/oldnewthing/20191125-00/?p=103135

Biterider