Click here to Skip to main content
15,900,973 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi i know about an api to open files, with default windows program.
For istance if in my Windows PDF will be open by acrobat the api will be point to that program, can you rembmer the api name?
Posted

 
Share this answer
 
v2
If you want the file extension to be opened with your program (or any other), you must add entries in the registry.

If you're using MFC, in the wizard, in "Document Template Properties", "File Extension", you add the extension (for example "zzz") and it generates the code itself.

In the registry, the shell open operations go in HKEY_CLASSES_ROOT/.zzz.

If you have an MFC project, the registration occurs in CWinApp::RegisterShellFileTypes.

The .reg the MFC generates looks something like:
REGEDIT
; This .REG file may be used by your SETUP program.
;   If a SETUP program is not available, the entries below will be
;   registered in your InitInstance automatically with a call to
;   CWinApp::RegisterShellFileTypes and COleObjectFactory::UpdateRegistryAll.

HKEY_CLASSES_ROOT\.zzz = DDZ.Document
HKEY_CLASSES_ROOT\DDZ.Document\shell\open\command = DDZ.EXE %1
HKEY_CLASSES_ROOT\DDZ.Document\shell\open\ddeexec = [open("%1")]
HKEY_CLASSES_ROOT\DDZ.Document\shell\open\ddeexec\application = DDZ
    ; note: the application is optional
    ;  (it defaults to the app name in "command")

HKEY_CLASSES_ROOT\DDZ.Document = DDZ.Document


If you really want really complex file extension management, you should create a shell extension dll. There is an excelent article on CodeProject:


The Complete Idiot's Guide to Writing Shell Extensions - Index[^]
 
Share this answer
 
As SAKryukov said you can use ShellExecute, Make sure to initialize COM.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900