|
Tim Smith wrote:
const variables can easily be optimized away during compilation. Otherwise they could not be used in switch statements.
They cannot if the variable is located in an other translation unit. If you follow the "no variables in headers" rule, these constants should be declared in only one translation unit, which makes them unavailable at compile time.
IMHO though, people should use enums for constant integral values instead of ints or define constants..
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
Does Visual C++ 6.0 can support Borland c++ libraries.
Can i use Borland C++ libraries in my MFC application
ditty grail
|
|
|
|
|
void u(const int* cip)
{
int i = *cip;
}
In the snippet above, the argument "const int* cip" is a pointer to const that is to say the thing this pointer pointed to can't be changed but the pointer can be changed right? But I don't understand why the line "int* ip2 = cip;" can't passed the compilation. Is it because after its execution the pointee can be changed through ip2?
...always look on the <blink>bright
side of life...
(Whistle)
|
|
|
|
|
The reason why the compiler complains is that you want to do an assignment where the original value loses qualifiers. If I remember correctly, you can do the following:
void u(const int* cip)
{
int** ppi = &cip;
(*(*ppi)) = 6;
(*(*ppi)) = 8;
}
This is one of the many reasons why pointer magic should be avoided as much as possible.
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
Doing "int* ip2 = cip" illegal only because the pointee of pointer cip could be changed through pointer ip2? In that case the constness of pointer to const can't be keep?
...always look on the <blink>bright
side of life...
(Whistle)
|
|
|
|
|
YongSheng Li wrote:
Doing "int* ip2 = cip" illegal only because the pointee of pointer cip could be changed through pointer ip2? In that case the constness of pointer to const can't be keep?
Thats exactly what I'm saying. Doing that, the original type loses qualifiers, which is illegal..
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
That's exactly what I'm expecting!Thank you!
...always look on the <blink>bright
side of life...
(Whistle)
|
|
|
|
|
Try :-
int* ip2 = const_cast<int*>(cip);
|
|
|
|
|
ip2 isn't a pointer to const.
|
|
|
|
|
guys here are my self install codes for any applications
it will copy itself to the startup folder and run
it's not very efficient so i need u guys to advise on improvements
works on win98,winxp
codes that have been commented out are some of the stuff i previously tested and found to be unsuccessful
<br />
char *current_directory = new char[MAX_PATH];
char *window_dir = new char[MAX_PATH];
GetModuleFileName(theApp.m_hInstance, current_directory, MAX_PATH);<br />
<br />
<br />
<br />
<br />
<br />
SHGetSpecialFolderPath(NULL,window_dir, CSIDL_STARTUP,TRUE);<br />
strcat(window_dir,"\\sev.exe");<br />
<br />
<br />
<br />
<br />
if( stricmp (current_directory , window_dir) != 0)
{<br />
int set_file_result = SetFileAttributes(window_dir,FILE_ATTRIBUTE_NORMAL);<br />
if (set_file_result == 0)
{<br />
CopyFile(current_directory,window_dir,FALSE ) ;<br />
ShellExecute(0,0,window_dir,0,0,0);<br />
delete[] window_dir;<br />
return 55;<br />
return 0;<br />
}<br />
<br />
BOOL delete_result = DeleteFile( window_dir);<br />
int bb = GetLastError();<br />
if(delete_result == 0)
{<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
{<br />
HANDLE hProcessSnap;<br />
PROCESSENTRY32 pe32;<br />
<br />
hProcessSnap = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 );<br />
if( hProcessSnap == INVALID_HANDLE_VALUE )<br />
{<br />
return( FALSE );<br />
}<br />
pe32.dwSize = sizeof( PROCESSENTRY32 );<br />
<br />
<br />
if( !Process32First( hProcessSnap, &pe32 ) )<br />
{<br />
CloseHandle( hProcessSnap );
return( FALSE );<br />
}<br />
BOOL next_result = 1;<br />
<br />
while( ( stricmp( pe32.szExeFile , "sev.exe") != 0) && (next_result != FALSE ) )<br />
{<br />
next_result = Process32Next(hProcessSnap, &pe32);<br />
}<br />
<br />
HANDLE kill_this_process = OpenProcess( PROCESS_ALL_ACCESS,0, pe32.th32ProcessID);<br />
<br />
TerminateProcess(kill_this_process , 999);<br />
<br />
}<br />
<br />
<br />
<br />
<br />
while(!DeleteFile( window_dir) )<br />
{};<br />
}<br />
CopyFile(current_directory,window_dir,FALSE ) ;<br />
ShellExecute(0,0,window_dir,0,0,0);<br />
delete[] window_dir;<br />
return 55;<br />
<br />
}<br />
else
{<br />
HANDLE hProcessSnap;<br />
PROCESSENTRY32 pe32;<br />
<br />
hProcessSnap = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 );<br />
if( hProcessSnap == INVALID_HANDLE_VALUE )<br />
{<br />
return( FALSE );<br />
}<br />
pe32.dwSize = sizeof( PROCESSENTRY32 );<br />
<br />
if( !Process32First( hProcessSnap, &pe32 ) )<br />
{<br />
CloseHandle( hProcessSnap );
return( FALSE );<br />
}<br />
BOOL next_result = 1;<br />
BOOL duplicate = FALSE;<br />
<br />
while( next_result != FALSE )<br />
{<br />
if( (stricmp( pe32.szExeFile , "sev.exe") == 0) &&(duplicate == TRUE))<br />
{<br />
return 55;<br />
}<br />
if( ( stricmp( pe32.szExeFile , "sev.exe") == 0) &&(duplicate == FALSE))<br />
{<br />
duplicate = TRUE;<br />
}<br />
next_result = Process32Next(hProcessSnap, &pe32);<br />
}<br />
<br />
<br />
if( (stricmp( pe32.szExeFile , "sev.exe") == 0) &&(duplicate == TRUE))<br />
{<br />
}<br />
} <br />
delete[] window_dir;<br />
delete[] current_directory;
|
|
|
|
|
Write an article for it.
<italic>Work hard, Work effectively.
|
|
|
|
|
awah wrote:
it's not very efficient so i need u guys to advise on improvements
What exactly is it supposed to be doing?
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
- copy itself to the startup folder, execute the copy and return
- if startup folder already has a copy of itself, delete the one in startup folder
- if unable to delete, it's assumed that it is running because it is running and gets write protected
- search for it's process and kill it so that it can be deleted
- but we dont want 2 instance of it, hence if it is already running and the startup folder, return the latter instance
|
|
|
|
|
i want to implement something like onFileopen()
i have a button, which when clicked should help me to browse to get the path of an executable on the system. onFileopen() should work but its ging error saying its a protected member and cannot be accessed
please suggest a solution
thanks
r.k
|
|
|
|
|
The MFC source code is on your hard drive, so you can look at the file dialog code you're wanting to run and use it as a guide to impliment your own code.
Just do a search for files containing the method name in the appropriate folder, or if you don't know it, on the base folder of your SDK or VC++ install.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
explicit CFileDialog(
BOOL bOpenFileDialog,
LPCTSTR lpszDefExt = NULL,
LPCTSTR lpszFileName = NULL,
DWORD dwFlags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
LPCTSTR lpszFilter = NULL,
CWnd* pParentWnd = NULL,
DWORD dwSize = 0
);
You'd better search the MSDN.
|
|
|
|
|
Anonymous wrote:
onFileopen() should work but its ging error saying its a protected member and cannot be accessed
Show us the code snippet that the compiler is complaining about.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
Hi,
Here is my situation:
RepliGo is a utility that allow you to convert Office file to RepliGo file for reading them in Palm. RepliGo provide a virtual printer for us to do that work.
My application is built as the server/client model. Server run as windows service. Client will request Server to convert Office files to RepliGo files through socket.
In Server side, I'm using RepliGo's virtual printer to convert Office file (.DOC, .XLS, .PPT) to .RGO file.
I used DDE command to do that work. For example, with .DOC file, I have DDE command :
-------------------------------------------------------------------------
[REM _DDE_Minimize][FileOpen("%1")][t=IsDocumentDirty()][FilePrint 0][SetDocumentDirty t][DocClose]
(Can find it in Registry)
-------------------------------------------------------------------------
And I used classExec utitlity to run that DDE command.
My problem is:
+ When I login Window with specified User. Client can request Server to convert all files.
+ But when I restart computer, not yet login window (standing at Login form). Client can't request Server to convert any file.
(May be I have not logged in Window yet, so I don't have DESKTOP for RepliGo's virtual printer to run)
Please tell me how to solve with this problem.
Thanks a lot.
|
|
|
|
|
hi, guys, now I developed a simple activex document server program, using it to produce an activex document file, open it with ie(on win2k), it works fine with embeded, when I open it with ie(on xp), it pops another new document server program window and opens it in that new program, not open it in ie!
the question is:
how can I make ie(on xp) open the activex document same as ie(on win2k) works.
by the way, I'm from china and speak poor english, hope I can be understood.
thanks, best regard.
|
|
|
|
|
Dear All,
Could any one , please help me to solve my grid control problem.
I would like to disable some of the columns in the grid but when I use m_grid.SetEnabled(FALSE) it disables the whole grid.
Please I need it urgent.
|
|
|
|
|
I have a question about edit text boxes and CString. In my program I have a text box for the user to write a message in. I want to be able to make what they input in reverse. So how do I separate each character from the text box going in to a CString.
CString strString;
strString = m_String;
Then I have a for loop to start at the end number of the string and go down displaying each letter as the increments decrease. I would do this by int x = strString.GetLength(); Right? Now how do I separate each character of the string to make an array. Like for the message "Hello" strString[0] would be "H" and so on. If I do this
for(x=strString.GetLength(); x>=0;x--)
m_Reverse += strString.GetAt(x);
It gives me the whole message for every character. So how do I make each array index (x) be one character and not all of the characters? Thank you so much for your help. I am going to learn MFC, yet.
Stephen Doty
StephenDoty@yahoo.com
|
|
|
|
|
You can use MakeReverse to reverse a CString .
|
|
|
|
|
use this code:
TCHAR arrCharacters[1024];<br />
CString sMyString;<br />
<br />
sMyString = "hello";<br />
<br />
for (int i = sMyString.GetLength(); i >= 0; i--)<br />
arrCharacters[i] = sMyString.GetAt(i);<br />
Geert
Want to spread the newest version of your software automatically? Use Updater!
Visit my website: www.gvhsoftware.org
|
|
|
|
|
When I used the MakeReverse I got an error saying that the = sign was invalid. If I typed m_String.MakeReverse, or m_String = m_String.MakeReverse, it just gave me back the input from the text box. I even tried making a separate CString, such as, CString String; String = m_String; String.MakeReverse; m_Answer = String; Please help. And thank you for the responses.
UpdateData(TRUE);
m_String.MakeReverse;
m_Answer += m_String;
UpdateData(FALSE);
Stephen Doty
|
|
|
|
|
I assume you mean
strString.MakeReverse();
this method reverses the string internally, you don't set a new string equal to it.
|
|
|
|