Click here to Skip to main content
15,929,263 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: How can I change dwStyle ? Pin
prasad_som20-Dec-06 18:02
prasad_som20-Dec-06 18:02 
GeneralRe: How can I change dwStyle ? Pin
Niamorh20-Dec-06 22:07
Niamorh20-Dec-06 22:07 
QuestionPre-compiled file Pin
John Shaft18-Dec-06 9:07
John Shaft18-Dec-06 9:07 
QuestionRe: Pre-compiled file Pin
Maximilien18-Dec-06 9:13
Maximilien18-Dec-06 9:13 
AnswerRe: Pre-compiled file Pin
John Shaft18-Dec-06 9:37
John Shaft18-Dec-06 9:37 
GeneralRe: Pre-compiled file Pin
Maximilien18-Dec-06 10:13
Maximilien18-Dec-06 10:13 
QuestionCREATE AND TERMINATE PROCESS USING WMI Pin
abhiramsss18-Dec-06 9:04
abhiramsss18-Dec-06 9:04 
QuestionAssign a file type to my program Pin
VeRtRX18-Dec-06 7:51
VeRtRX18-Dec-06 7:51 
Hi,

I have my own file format and a program loading those files.

Under Windows XP i got the automatic file asssignment working, but it doesn't work under windows Vista. So i think i didn't do it correctly under XP, maybe it only works there by accident Wink | ;) .

Do you guys know how to automatically assign (what to write into registry) a file format to a program (which also works under Windows Vista)?

Here is how i do it:

<br />
void RegisterFileType(const String& extension,<br />
					  const String& fileRegisterName,<br />
					  const String& fileExplorerName)<br />
{<br />
	// get applications path<br />
	TCHAR buffer[1024];<br />
	GetModuleFileName(NULL, buffer, 1024);<br />
	CString applicationFileName = buffer;<br />
<br />
	// register file extension<br />
	CRegistry keyFileExtension;<br />
	keyFileExtension.CreateKey(HKEY_CLASSES_ROOT, extension.AsChar());<br />
	CString standard = _T(fileRegisterName.AsChar());<br />
	keyFileExtension.SetValue("", standard);<br />
	keyFileExtension.CloseKey();<br />
<br />
	// set name which appears in the explorer<br />
	CRegistry LMFile;<br />
	CString fileName = _T(fileExplorerName.AsChar());<br />
	LMFile.CreateKey(HKEY_CLASSES_ROOT, standard);<br />
	LMFile.SetValue("", fileName);<br />
	LMFile.CloseKey();<br />
<br />
	// set the default icon for the files<br />
	CRegistry keyDefaultIcon;<br />
	CString defaultIcon = standard;<br />
	defaultIcon += "\\DefaultIcon";<br />
	keyDefaultIcon.CreateKey(HKEY_CLASSES_ROOT, defaultIcon);<br />
	CString iconPath = applicationFileName + ", 0";<br />
	keyDefaultIcon.SetValue("", iconPath);<br />
	keyDefaultIcon.CloseKey();<br />
<br />
	// prepare shell<br />
	CRegistry shell;<br />
	CString shellPath = standard;<br />
	shellPath += "\\shell";<br />
	shell.CreateKey(HKEY_CLASSES_ROOT, shellPath);<br />
	shell.CloseKey();<br />
<br />
	CRegistry open;<br />
	CString openPath = standard;<br />
	openPath += "\\shell\\open";<br />
	open.CreateKey(HKEY_CLASSES_ROOT, openPath);<br />
	open.CloseKey();<br />
<br />
	// create open command<br />
	CRegistry command;<br />
	CString commandPath = standard;<br />
	commandPath += "\\shell\\open\\command";<br />
	command.CreateKey(HKEY_CLASSES_ROOT, commandPath);<br />
	CString a = "\"";<br />
	CString cs = a + applicationFileName + a + CString(" ") + a + CString("%1") + a;<br />
	command.SetValue("", cs);<br />
	command.CloseKey();<br />
}<br />


Do i miss anything? Or do i do something incorrectly?

Hope you guys can help me!

Thanks a lot in advance and i hope to hear from you soon.


- Ben
AnswerRe: Assign a file type to my program Pin
VeRtRX20-Dec-06 21:58
VeRtRX20-Dec-06 21:58 
AnswerRe: Assign a file type to my program Pin
Mark Salsbery21-Dec-06 5:38
Mark Salsbery21-Dec-06 5:38 
QuestionHow do you add checkbox controls at runtime Pin
Sparky-D18-Dec-06 7:34
Sparky-D18-Dec-06 7:34 
AnswerRe: How do you add checkbox controls at runtime Pin
Waldermort18-Dec-06 7:38
Waldermort18-Dec-06 7:38 
AnswerRe: How do you add checkbox controls at runtime Pin
Hamid_RT18-Dec-06 18:36
Hamid_RT18-Dec-06 18:36 
AnswerRe: How do you add checkbox controls at runtime Pin
Abhijeet Rajput19-Dec-06 0:58
Abhijeet Rajput19-Dec-06 0:58 
Questionshared memory Pin
Waldermort18-Dec-06 7:22
Waldermort18-Dec-06 7:22 
QuestionSetting Font size in CEdit control Pin
lee445588318-Dec-06 5:34
lee445588318-Dec-06 5:34 
AnswerRe: Setting Font size in CEdit control Pin
Steve S18-Dec-06 6:31
Steve S18-Dec-06 6:31 
AnswerRe: Setting Font size in CEdit control Pin
Hamid_RT18-Dec-06 17:53
Hamid_RT18-Dec-06 17:53 
QuestionScolling for a CFormView Pin
DanYELL18-Dec-06 5:10
DanYELL18-Dec-06 5:10 
QuestionStatic declaration behaviour within MFC dialog Pin
Like2Byte18-Dec-06 5:02
Like2Byte18-Dec-06 5:02 
AnswerRe: Static declaration behaviour within MFC dialog Pin
Like2Byte18-Dec-06 5:49
Like2Byte18-Dec-06 5:49 
AnswerRe: Static declaration behaviour within MFC dialog Pin
Chris Losinger18-Dec-06 5:51
professionalChris Losinger18-Dec-06 5:51 
Generalcreating wrapper Pin
V.18-Dec-06 4:39
professionalV.18-Dec-06 4:39 
GeneralRe: creating wrapper Pin
Chris Losinger18-Dec-06 4:49
professionalChris Losinger18-Dec-06 4:49 
QuestionCComboBox height Pin
Demian Panello18-Dec-06 2:45
Demian Panello18-Dec-06 2:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.