hi
i used GetModuleFileName and GetModuleBaseName functions to return the path(directory) for the folder the project is in and the icon as well ...like this:

void CForm1::OnCommand1()
{
// TODO: Add your control notification handler code here
CComVariant retval; // - "AutoDim"
CString toto="ccc_ext";
CString app_path;
CString Icon;
char buffer2[2048];
HANDLE hProcess = GetCurrentProcess();
char buffer1[2048];

app_path=GetModuleFileName(NULL, buffer2, 2048)+"\\"+GetModuleBaseName(hProcess, NULL, buffer1, 2048);
Icon=GetModuleFileName(NULL, buffer2, 2048) +"\\" ;


retval = Associate_File(".ccc", app_path,toto,"My own extension",Icon);
AfxMessageBox(("Associated the file extension .ccc with this application!"));

}

but when i check the registry .... i found afolder for the extension but with no directory for the command or the icon
whats wrong ?
pleeease help me with this
thank u

Recommended Answers

All 9 Replies

What makes you believe that information is in the registry ?

because as patially u can see in my code that iam trying to create afile type association....
i tried a demo with different extension....".abd"
and after running it i can find the information with the directories in it
>> and in my own file type ....i cant
I dont know why
can u tell what is it i missing
thanks

check that the file type doesn't already exist/is already registered by another prog

GetFileName() and GetModuleBaseName() have nothing at all to do with registering file extensions. Extensions are registered in KEY_CLASS_ROOTS

GetFileName() and GetModuleBaseName() have nothing at all to do with registering file extensions. Extensions are registered in KEY_CLASS_ROOTS

I Know that... but i need these two functions to return the path for the program and for the icon to be used for the file type.

check that the file type doesn't already exist/is already registered by another prog

NO ... it is not .... i checked

I'm now confused about what you are trying to do. Neither of those functions will read the registry and give you an icon for the file type. In fact there is no function that will do that because there are no standard icons for specific file types. The icons for MS-Windows applications are included in the program's resource, which is part of the *.exe and it can be anything the developer chooses it to be.

The icons for MS-Windows applications are included in the program's resource, which is part of the *.exe and it can be anything the developer chooses it to be.

ok
this is what iam trying to do:
in my application that iam trying to create a file type for ,i use these functions to return the path of the ".exe" and the icon of the application such as:
C:\Documents and Settings\MooN PC\Desktop\my folder\project\file associate\book.ico
C:\DocumentsandSettings\MooNPC\Desktop\myfolder\project\fileasspciate\
File_associate.exe" "%1

//*************************************************************************//
and what iam talking about in registry is... to make sure that i have a correct made file type ineed to check the folder for that type such as ".ccc" (manually)
and find if the path is correct for the open command and the defaulticon.
which is not in my situation ...
(it is all about checking) THATS ALL
//*****************************************************************//
now every thing is going fine and the application is running well. but when try to rename for example "ex.txt" to "ex.abd" it would chang correctly to the file type and the icon also change and it can be opend by the new type. where in my "ex.ccc" it would change to unknown file type and cannot be open and need to choose aprogram to open with.
//*******************************************************************//
i hope the picture is clear for u now
so , can u help me with this?
thank u

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.