|
ok
the problem is that
in the application demo that i have, when pressing the button....amessage box appears saying that the file type .abd has been associated
and when naming any text file with .abd ..... it would be open in the demo program showing the content of the file in the dialog box....ok
when i tried to do it my self with another extension".ccc"
everything going good when pressing abutton saying the same thing and eveything ....but where is the difference?
it is when i try to name a text file with the extension .ccc nothing happend and icant open it "it wont see the file type"....
and also as i said before when checking and comparing the .abd AND .ccc
i found that .abd has directory for the command and the defaulticon...where for the .ccc there is not just something like"s+I" or ")]"
which is nothing exactly
i dont know what is wrong
did u get the idea?
iam really stuck in this
thanks for ur PATIENCE
|
|
|
|
|
lahom wrote: it is when i try to name a text file with the extension .ccc nothing happend and icant open it "it wont see the file type"....
Check to make sure that you successfully renamed the file extension.
(Depending on which version of Windows OS you use)
There is an option in Windows explorer settings. Under Windows Explorer's Tools menu, there is a menu command "Folder Options...", if you run it, Folder Options dialog box pops up. In view tab of this dialog, you will see "Advanced Settings:" control, find "Hide extensions of known file types" check box and clear it (remove check mark). Then, have a look the file which you wanted to rename. txt extension may still there.
Which version of Windows OS you use?
|
|
|
|
|
iam sorry ...maybe i wasnot clear enough
Ozer Karaagac wrote: lahom wrote:
it is when i try to name a text file with the extension .ccc nothing happend and icant open it "it wont see the file type"....
i didnt mean it like that .
what i menti is that when i rename "example.txt"
to "example.ccc"
the file would chang to unknown file and need to open with "open with"
which is not the case in "example.abd"
where it would open normally in the demo application specified before.
i hope i was clear this time
by the way "i use windows xp pro"
|
|
|
|
|
Well, what are the Default values of shell/open/command and DefaultIcon of the file type when you look into them by regedit? You may also use "Advanced" button in "File Types" tab of Folder Options dialog box.
If shell/open/command points a file which can not be found, file association won't be valid.
|
|
|
|
|
Ozer Karaagac wrote: what are the Default values of shell/open/command and DefaultIcon of the file type when you look into them by regedit?
ok
for the "example.abd"it is as the following:
folder: ext_abd (Default) REG_SZ My own extension
folder: Defaulticon (Default) REG_SZ C:\Documents and Settings\MooNPC\Desktop\my folder\project\FileAssociate_demo\book.ico
folder: shell (Default) REG_SZ (value not set)
folder: open (Default) REG_SZ (value not set)
folder: command (Default) REG_SZ "C:\Documents and Settings\MooN PC\Desktop\my folder\project\FileAssociate_demo\File_associate.exe" "%1"
//**************************************************************//
but for the "example.ccc" it is like this:
folder: ext_ccc (Default) REG_SZ <+B
folder: Defaulticon (Default) REG_SZ ce)B
folder: shell (Default) REG_SZ (value not set)
folder: open (Default) REG_SZ (value not set)
folder: command (Default) REG_SZ \$B
//*********************************************************************//
this is what is shown in the regedit
so
what do u think?
help pleeease
|
|
|
|
|
Yes. They all seemed garbage values.
It also seems that some of the parametes, are passed to Associate_File() funtion, have a problem including 4th parameter which is just a string (i.e. "My own extension"). However, another string parameter "ext_ccc" have not. Because a registry key has been created with that name. I think, the problem may be in Associate_File() funtion. At first, we have to be sure for the parameter values which are passed to Associate_File() funtion.
Could you please re-post your code snippet with the latest changes that you've posted earlier?
And how do you use strings in your project ANSI or UNICODE?
|
|
|
|
|
ok
this is the associate file function:
CComVariant Associate_File(CString Extension, CString Application, CString &Identifier, CString Description, CString Icon)<br />
{<br />
CComVariant Associate_File;<br />
<br />
LONG lRtn;
HKEY hKey = NULL;
int lValue;
CString sValue;
int lsize;
CString commandline;<br />
DWORD dwDisp;<br />
lRtn = RegCreateKeyEx(HKEY_CLASSES_ROOT, Extension, 0, "", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, 0, &hKey, &dwDisp);<br />
<br />
if (lRtn!=ERROR_SUCCESS) {<br />
AfxMessageBox(CreateErr);<br />
}<br />
<br />
lsize = Identifier.GetLength();
lRtn = RegSetValueExA(hKey, "", 0, REG_SZ, (const unsigned char*)&Identifier, lsize);<br />
if (lRtn!=ERROR_SUCCESS) {<br />
AfxMessageBox("Error Setting String Value!");<br />
RegCloseKey((hKey));<br />
return Associate_File;<br />
}<br />
<br />
RegCloseKey((hKey));<br />
<br />
lRtn = RegCreateKeyEx(HKEY_CLASSES_ROOT, Identifier, 0, "", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, 0, &hKey, &dwDisp);<br />
<br />
if (lRtn!=ERROR_SUCCESS) {<br />
AfxMessageBox(CreateErr);<br />
}<br />
<br />
lsize = Description.GetLength();
lRtn = RegSetValueExA(hKey, "", 0, REG_SZ, (const unsigned char*)&Description, lsize);<br />
if (lRtn!=ERROR_SUCCESS) {<br />
AfxMessageBox("Error Setting String Value!");<br />
RegCloseKey((hKey));<br />
return Associate_File;<br />
}<br />
<br />
RegCloseKey((hKey));<br />
<br />
<br />
lRtn = RegCreateKeyEx(HKEY_CLASSES_ROOT, (Identifier+"\\DefaultIcon"), 0, "", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, 0, &hKey, &dwDisp);<br />
<br />
if (lRtn!=ERROR_SUCCESS) {<br />
AfxMessageBox(CreateErr);<br />
}<br />
<br />
lsize = Icon.GetLength();
<br />
lRtn = RegSetValueExA(hKey, "", 0, REG_SZ, (const unsigned char*)&Icon, lsize);<br />
if (lRtn!=ERROR_SUCCESS) {<br />
AfxMessageBox("Error Setting String Value!");<br />
RegCloseKey((hKey));<br />
return Associate_File;<br />
}<br />
<br />
RegCloseKey((hKey));<br />
<br />
<br />
<br />
Identifier += "\\shell";<br />
<br />
lRtn = RegCreateKeyEx(HKEY_CLASSES_ROOT, Identifier, 0, "", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, 0, &hKey, &dwDisp);<br />
<br />
if (lRtn!=ERROR_SUCCESS) {<br />
AfxMessageBox(CreateErr);<br />
}<br />
<br />
RegCloseKey((hKey));<br />
<br />
<br />
Identifier += "\\open";<br />
<br />
lRtn = RegCreateKeyEx(HKEY_CLASSES_ROOT, Identifier, 0, "", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, 0, &hKey, &dwDisp);<br />
<br />
if (lRtn!=ERROR_SUCCESS) {<br />
AfxMessageBox(CreateErr);<br />
}<br />
<br />
RegCloseKey((hKey));<br />
<br />
<br />
Identifier += "\\command";<br />
<br />
lRtn = RegCreateKeyEx(HKEY_CLASSES_ROOT, Identifier, 0, "", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, 0, &hKey, &dwDisp);<br />
<br />
if (lRtn!=ERROR_SUCCESS) {<br />
AfxMessageBox(CreateErr);<br />
}<br />
<br />
commandline = (Str(CString(char(34)))+Application+Str(CString(char(34)))+" "+Str(CString(char(34)))+"%1"+Str(CString(char(34))));<br />
lsize = commandline.GetLength();
lRtn = RegSetValueExA(hKey, "", 0, REG_SZ, (const unsigned char*)&commandline, lsize);<br />
if (lRtn!=ERROR_SUCCESS) {<br />
AfxMessageBox("Error Setting String Value!");<br />
RegCloseKey((hKey));<br />
return Associate_File;<br />
}<br />
<br />
RegCloseKey((hKey));<br />
return Associate_File;<br />
}
this is the button event:
void CForm1::OnCommand1()<br />
{<br />
CComVariant retval;
CString exten="ccc_ext";<br />
CString app_path;<br />
CString Icon;<br />
char buffer2[2048];<br />
HANDLE hProcess = GetCurrentProcess();<br />
char buffer1[2048];<br />
DWORD r1 = GetModuleBaseName(hProcess, NULL, buffer1, 2048); <br />
app_path=GetModuleFileName(NULL, buffer2, 2048)+"\\"+r1;<br />
Icon=r1+"\\book.ico" ;<br />
retval = Associate_File(".ccc", app_path,exten,"My own extension",Icon);<br />
AfxMessageBox(("Associated the file extension .ccc with this application!"));<br />
<br />
}
maybe there is something wrong with the type conversion....right
i think iam using UNICODE
thank u
|
|
|
|
|
First of all, you aren't already using the functions that I've provided via my first reply in this thread.
You should find them and copy&paste to your source file before the line void CForm1::OnCommand1().
Then, replace that function with the one below.
void CForm1::OnCommand1()
{
CComVariant retval;
CString exten="ccc_ext";
CString app_path = GetExeName();
CString Icon = GetExeFolder() + "\\book.ico";
retval = Associate_File(".ccc", app_path, exten, "My own extension", Icon);
AfxMessageBox(("Associated the file extension .ccc with this application!"));
}
I didn't want to post whole Associate_File() function that might mess up the board.
So, please find and replace all commented lines below with uncommented ones in Associate_File() function.
lRtn = RegSetValueExA(hKey, "", 0, REG_SZ, (LPBYTE)(LPCTSTR)Identifier, lsize);
lRtn = RegSetValueExA(hKey, "", 0, REG_SZ, (LPBYTE)(LPCTSTR)Description, lsize);
lRtn = RegSetValueExA(hKey, "", 0, REG_SZ, (LPBYTE)(LPCTSTR)Icon, lsize);
commandline = '\"' + Application + "\" \"%1\"";
lRtn = RegSetValueExA(hKey, "", 0, REG_SZ, (LPBYTE)(LPCTSTR)commandline, lsize);
It worked well in my system.
BTW, strings are not UNICODE.
|
|
|
|
|
IT WORKED
Iam reeeeealy thankful to u
i cant really thank u enough
THANK U
|
|
|
|
|
You're welcome.
|
|
|
|
|
lahom wrote: but with no directory shown in the right pane of regedit
Do you mean directory part of the fully qualified pathname?
like "C:\some.exe" or just "some.exe" for the action command.
|
|
|
|
|
Well this code is for vb but do you want to concatenate strings?
|
|
|
|
|
Hi, I'm beginner. I tried run project (http://opensteer.sourceforge.net/[^]). There is a main program and a few ready plugins. I compiled and run *.exe, but when I was switching plugins, traying run the last one (The most and only one important to me) "soccer" I had a message box:
------------
Microsoft Visual C++ Debug Library
Debug Assertion Failed!
Program: E:\opensteer\win32\bin\OpenSterDemo_d.exe
File: c:\progeam files\microsoft visual studio 8\vc\include\vector
Line: 1463
Expression: vector<bool> iterator not dereferencable
For information on how your program can cause an asseration
failure, see the Visual C++ documentation on asserts.
-------------
Could anybody help me ? please....
regards, Daniel.
PS: If something, maybe My english, is not understable I can try write in other way.
thx
|
|
|
|
|
This is not exactly a programming question. You should ask for help in the stree forum[^].
-Saurabh
|
|
|
|
|
I know that OpenSterr has own forum, but here are more people and... very smart
If, however, somebody could tell me something important, i'll be grateful.
Btw. after this msg. when I click IGNORE, I've last msg.:
//after choose IGNORE in msg box, next:
Microsoft Visual C++ Debug Library
Debug Assertion Failed!
Program: E:\opensteer\win32\bin\OpenSterDemo_d.exe
File: c:\progeam files\microsoft visual studio 8\vc\include\vector
Line: 1463
Expression: ("Standard C++ Libraries Out of Range", 0)
For information on how your program can cause an asseration
failure, see the Visual C++ documentation on asserts.
Thx anyway, BR.
Daniel.
|
|
|
|
|
What I need is very simple, copy some file to a directory where the application is.
|
|
|
|
|
|
Do you need to SHFileOperation?
|
|
|
|
|
I have a class that wraps a std::map (never mind why). To make it seamless to use I re-implement a number of the functions found on std::map, like find(), begin(), erase(), insert(), etc, and then just call the underlying map collection.
So I am working on porting this code to the Mac (which means I'm going to be pissing and moaning the rest of the day) and came across this gem:
error: conversion from 'void' to non-scalar type 'std::_Rb_tree_iterator<std::pair><const std::string,="" int=""> >' requested
</const></std::pair>
After digging and silently swearing under my breath I find that the GCC implementation of std::map::erase is different than what you find on Microsoft (note that the code worked on ALL versions of MS C++ from VC6 to VC9). Microsoft's is like this:
iterator erase( iterator i );
GCC's
void erase( iterator i );
So who's right?
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
Save an Orange - Use the VCF!
VCF Blog
|
|
|
|
|
Generally when I have doubts about STL I check SGL STL[^].
In this case MSDN clearly says that return type of map does not conform to the C++ standard link[^].
-Saurabh
|
|
|
|
|
Grrrr why would they (MS) do that? I can see the mistakes in the VC6 version, but why keep promoting it through the other versions of the compiler???
Anyhow thanks for the info!
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
Save an Orange - Use the VCF!
VCF Blog
|
|
|
|
|
Don't know my MS decided to do it this way but once C++0x is officially released MS implementation will be correct and other STL vendors will have to make the correction. In C++0x all containers erase functions should return iterator one past erased iterator n2350[^].
-Saurabh
|
|
|
|
|
because they value functionality and backwar compatibility over standard compliance?
It supposedly makes it more obvious to selectively erase items from a list while iterating through it:
for(it=cont.begin(); it!=cont.end();)
{
if (ToUglyToKiss(*it))
it = cont.erase(it);
else
++it;
}
otherwise:
for(it=cont.begin(); it!=cont.end();)
{
iterator cur = it;
++it;
if (ToUglyToKiss(*cur))
cont.erase(cur);
}
well, not to bad either, but I see how it can make a difference in more complex code.
We are a big screwed up dysfunctional psychotic happy family - some more screwed up, others more happy, but everybody's psychotic joint venture definition of CP blog: TDD - the Aha! | Linkify!| FoldWithUs! | sighist
|
|
|
|
|
hi all
is there any help to say , what is the best Book Or Reference for Visual c++ .
I'm new in visual c++
thanx very lot
s_mostafa_h
|
|
|
|
|
If one book could take you from beginner to intermediate programmer, (in Visual C++) it would have to be Ivor Horton's "Beginning Visual C++ 6" or there are versions for VC++ 2005 and VC++ 2008.
They are all basically the same except the newer ones add some odd chapters on WinForms and a small dose of .NET for completeness.
First half of the book teaches C++, the second half is about Windows programming. MFC is the dominant class library used.
|
|
|
|
|