Click here to Skip to main content
15,893,622 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I created a VLC media player and single Document applications using vc6,when i had saved the file with my own extension(like *.123,*.myavi) the file appears like a raw file and i must choose my exe to opened it in every time.

how can i launch my own application (like MYNOTEPAD ,MYPLAYER )?
Posted
Comments
Sergey Alexandrovich Kryukov 25-Feb-12 18:44pm    
No, you did not create the VLC media player. Those who created it know do how to register application type :-)

--SA
rajesh482 5-Jun-13 6:07am    
This is the code to register extenstion
=============================================
int RegisterExtenstion( )
{
HKEY hkey;

if (ERROR_SUCCESS==RegOpenKey(HKEY_CLASSES_ROOT,".mfe",&hkey))
{
RegCloseKey(hkey);
AfxMessageBox("This Extension is already registered");
GetDlgItem(IDOK)->ShowWindow(SW_HIDE);
return ;
}
CString sExt=".mfe";
CString sDescription="My File Extension";

sDescription.Replace(" ",""); //revoing spaces in Description
sExt.Replace(" ",""); // sExt – extension to register

sExt.Replace(".","");
sExt="."+sExt;


CString app=GetCommandLine(); // Getting the application Path

app.TrimLeft(_T("\"")); app.TrimRight(_T("\""));

CString str,strIcon;
str.Format(_T("%s"),app);
PathRemoveFileSpec((LPTSTR)(LPCTSTR)str) ; //for this #include "Shlwapi.h" //#pragma comment(lib,"Shlwapi.lib")
strIcon.Format(_T("%s\\Sample.ico \0"),str);//place "Sample icon" in exe folder

app+=" \"%1\"";

RegOpenKeyEx(HKEY_CLASSES_ROOT,"",0,KEY_QUERY_VALUE,&hkey);
DWORD dw;

RegCreateKeyEx(hkey, sExt.operator LPCTSTR() , 0L, NULL,
REG_OPTION_NON_VOLATILE,
KEY_ALL_ACCESS,
NULL,&hkey, &dw );

CString key=sDescription;

RegSetValueEx(hkey,"",0,REG_SZ,(BYTE *)key.operator LPCTSTR(),
key.GetLength());
RegCloseKey(hkey);

RegOpenKeyEx(HKEY_CLASSES_ROOT,"",0,KEY_QUERY_VALUE,&hkey);

RegCreateKeyEx (hkey, key, 0L, NULL,
REG_OPTION_NON_VOLATILE,
KEY_ALL_ACCESS,
NULL, &hkey, &dw);

RegCreateKeyEx (hkey, "shell", 0L, NULL,
REG_OPTION_NON_VOLATILE,
KEY_ALL_ACCESS,
NULL,&hkey, &dw);

RegCreateKeyEx (hkey, "open", 0L, NULL,
REG_OPTION_NON_VOLATILE,
KEY_ALL_ACCESS,
NULL,&hkey, &dw);

RegCreateKeyEx (hkey, "command", 0L, NULL,
REG_OPTION_NON_VOLATILE,
KEY_ALL_ACCESS,
NULL,&hkey, &dw);

RegSetValueEx(hkey,"",0,REG_SZ, (LPBYTE)(LPCTSTR)app,app.GetLength());
RegCloseKey(hkey);

RegOpenKeyEx(HKEY_CLASSES_ROOT,key,0,KEY_QUERY_VALUE,&hkey);
RegCreateKeyEx (hkey, "DefaultIcon", 0L, NULL,
REG_OPTION_NON_VOLATILE,
KEY_ALL_ACCESS,
NULL,&hkey, &dw);

RegSetValueEx(hkey,"",0,REG_SZ, (LPBYTE)(LPCTSTR)strIcon,strIcon.GetLength());
RegCloseKey(hkey);; return 1; }

1 solution

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