|
CodingLover wrote: I mean on a debug mode I want to use some commands on the console. But they are not allowed to use in release mode.
#define DEBUG
. . .
#ifdef DEBUG
. . .
#endif
Now the code that you don't want to execute in the release mode goes in the above section.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
|
Thanks for all replays.
I appreciate your help all the time...
CodingLover
|
|
|
|
|
I have one question here.
I've call a function with a command in the console. Say by test
I want to add some parameters too, something like this.
test one two
What is the easiest way to get those values.
I appreciate your help all the time...
CodingLover
|
|
|
|
|
CodingLover wrote: What is the easiest way to get those values.
Are you asking about command line parameters? If so use GetCommandLine function.
Nibu thomas
Microsoft MVP for VC++
Code must be written to be read, not by the compiler, but by another human being.
Programming Blog: http://nibuthomas.wordpress.com
|
|
|
|
|
Yes, I've explain it in wrong way. I'll say it in this way.
Say my command parameter is text 0xAF 150
I want to get each of them as it is, mean a string, a DWORD and a int. Then pass each as command line parameters. What I'm looking is how to separate those values in standard C++
I appreciate your help all the time...
CodingLover
|
|
|
|
|
int main(int argc, char *argv[])
{
for (int i = 1; i < argc; i++) {
cout << argv[i] << " "; //argv[i] has separated command line params
}
cout << endl;
}
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
But how it's separated. According to my command, how can I separate them.
At the time just forget the command line concept. Because I do all those things in different classes and in different stages.
I appreciate your help all the time...
CodingLover
|
|
|
|
|
Your question still makes no sense.
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Ok sir, just forget about command line parameters and stuff.
I have a string text 0xAF 150
I want to separate them as a string, as a DWORD and as an int value respectively. How can I do it.
Hope it's clear now
I appreciate your help all the time...
CodingLover
|
|
|
|
|
If you are using MFC, check out AfxExtractSubString() . Otherwise, strtok() is an option.
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hi All,
How can I create a process with system level privilege?
Best Regards,
AJ
|
|
|
|
|
Hope this will work.
Call CreateProcess with fdwCreate flag as DEBUG_PROCESS.
akt
|
|
|
|
|
Does CreateProcessAsUser helpful?
|
|
|
|
|
I'm trying to post data from c++ code to my webservice, all works fine untill i throw in a slow network and dial-up connection. I then get a "The operation timed out" error, it always happens at exactly 30seconds, the fault is not at the webservive, his 5minute timeout is working. If someone could please just take a quick look at the code and tell me where i might have missed something.
This is my attempt to disable the timer, the value i put in appear to have no effect:
CInternetSession mySession(NULL, 1, PRE_CONFIG_INTERNET_ACCESS, NULL,
NULL, 0);
CHttpConnection *pHttpConnection;
CHttpFile *pHttpFile;
CString szServerUrl, szObject;
CString strHeaders = _T("Content-Type: application/x-www-form-urlencoded");
mySession.SetOption(INTERNET_OPTION_CONNECT_TIMEOUT,0xFFFFFFFF,0);
Here is the complete code for anyone who might be interrested, it's taken from another project here on CodeProject, but I can't seem to locate it again:
DWORD Post(CString url, CString szFormData, CString & resultString)
{
CInternetSession mySession(NULL, 1, PRE_CONFIG_INTERNET_ACCESS, NULL,
NULL, 0);
CHttpConnection *pHttpConnection;
CHttpFile *pHttpFile;
CString szServerUrl, szObject;
CString strHeaders = _T("Content-Type: application/x-www-form-urlencoded");
mySession.SetOption(INTERNET_OPTION_CONNECT_TIMEOUT,0xFFFFFFFF,0);
szServerUrl = url;
ExtractObject(szServerUrl,szObject);
try
{
pHttpConnection = mySession.GetHttpConnection(szServerUrl);
if( NULL == pHttpConnection)
{
return WEB_ACCESS_UNEXPECTED_ERROR;
}
}
catch (CInternetException *pException)
{
char buffer[1023];
pException->GetErrorMessage(buffer, 1023);
resultString = buffer;
return pException->m_dwError;
}
try {
pHttpFile = pHttpConnection->OpenRequest(CHttpConnection::HTTP_VERB_POST, szObject);
if(NULL == pHttpFile)
{
return WEB_ACCESS_UNEXPECTED_ERROR;
}
}
catch(CInternetException *pException)
{
char buffer[1023];
pException->GetErrorMessage(buffer, 1023);
resultString = buffer;
return pException->m_dwError;
}
try {
BOOL ret = pHttpFile->SendRequest(strHeaders, (LPVOID)(LPCSTR)szFormData, szFormData.GetLength());
if( FALSE == ret )
{
return WEB_ACCESS_UNEXPECTED_ERROR;
}
}
catch(CInternetException *pException)
{
char buffer[1023];
pException->GetErrorMessage(buffer, 1023);
resultString = buffer;
return pException->m_dwError;
}
DWORD retCode;
BOOL ret = pHttpFile->QueryInfoStatusCode(retCode);
if( FALSE == ret )
{
return WEB_ACCESS_QUERY_INFO_ERROR;
}
else if( HTTP_STATUS_OK != retCode )
{
return retCode;
}
char buf[2];
int bytesRead;
resultString = "";
while( (bytesRead = pHttpFile->Read(buf, 1)) > 0 )
{
resultString += buf[0];
}
return WEB_ACCESS_DONE;
}
|
|
|
|
|
I've been struggling with this for days and as soon as i post i found a solution.
In any case, it seems i've been setting the wrong timer, this fixed the problem:
mySession.SetOption(INTERNET_OPTION_CONNECT_TIMEOUT,50000);
mySession.SetOption(INTERNET_OPTION_CONNECT_RETRIES, 3);
mySession.SetOption(INTERNET_OPTION_CONNECT_TIMEOUT, 50000);
mySession.SetOption(INTERNET_OPTION_DATA_RECEIVE_TIMEOUT,50000);
mySession.SetOption(INTERNET_OPTION_RECEIVE_TIMEOUT,50000);
mySession.SetOption(INTERNET_OPTION_DATA_SEND_TIMEOUT, 50000);
mySession.SetOption(INTERNET_OPTION_SEND_TIMEOUT, 50000);
|
|
|
|
|
I Want to convert char array into LPCTSTR ,std::string to LPCTSTR and DWORD to LPCTSTR
can any body help me to solve this.
|
|
|
|
|
Try the search box above with "string conversion". This is a task of learning to read code and documentation.
Greetings from Germany
|
|
|
|
|
Member 4620216 wrote: convert char array into LPCTSTR
If its UNICODE is defined, the LPCTSTR will expand as const wchar_t*. So you've to convert the char* to wchar_t* by using A2W macro. If its not UNICODE, then LPCTSTR is const char* and you can directly assign it. See the code block.
#ifdef UNICODE
#else
#endif
Member 4620216 wrote: std::string to LPCTSTR
call string.c_str() function.
Member 4620216 wrote: DWORD to LPCTSTR
Since DWORD is unsigned long , _ultot() can be used.
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|
|
Hello all,
I am facing a critical issue. I have my executable at server side which user downloads. User is able to download. Now i want that application to execute itself rather than forcing user to go to downloaded location and execute it. So how would i accomplish this? Is there any way on server side that run downloaded executable on client machine.?? I mean script or something??
Please help me out. Any help would be greatly appreciated.
Thanks & Regards,
Hemang
|
|
|
|
|
How is the download happening? You can execute the downloaded binary automatically, only if your program on the client machine is doing the download. If the user is doing the download manually, then he'll have to execute it.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
First Thanks for replying .
ACtually my program is doing download and execition. But for some specific reason it is not working for some of the client. So do not waant to change that client program as it is downloading perfectly and only getting problem in execution of that program
so do not want to force user to manually execute it but somehow execute downloaded exe by itself on client machine either from server or triggering some event while download so it will auto-execute downloaded file from its location
I look forward for further help.
Thanks & Regards,
Hemang
|
|
|
|
|
Hemang Raval wrote: getting problem
This is vague. What exactly is the 'problem'? I suggest that you try analyzing the log file of your application.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
I knew that it would be difficult to explain. You are right that it is also difficult for you to understand where exactl the problem is.
But can you please throw light in some other direction. Suppose i want to execute a particular application after it is downloaded. Is it possible for executable file that is being downloaded to execute itelf after its complete downloading or from server where it is being downloaded, can we do at that side (server) to execute it.
I may be silly asking such question but this kind of question arises when i think of spyware and viruses. Because nobody tell them to execute but they maliciously run after being downloaded.
So please further share your knowledge.
Thanks & Regards,
Hemang
Thankd
|
|
|
|
|
An binary will not be able to execute 'itself' after it's been downloaded. You either need a watchdog which will be monitoring the download to execute it upon completion. But as you already say that it is your own application that does the download, it could as well execute the file after download. If there are issues on specific computers, try logging the events from your application and find out what is causing this problem. You can use an external debugger like DebugView[^]to print debug strings (the name is misleading, works on release versions as well) if you wish not to use a log file.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|