|
Yes, but I don't know always how many decimal exist ...
|
|
|
|
|
You might as well ask "How many angels can dance on the head of a pin?".
You really need to read the article already linked http://support.microsoft.com/kb/42980[^] and embrace the idea that a "Binary Computer" cannot precisely represent every possible "Decimal Digit" that exists for floating point numbers. It is a fact of life.
Rather than try to figure out how many "decimals exist", you just need to determine "how many you care about". 6, 12, 18 are a pretty common need, unless you are doing planetary orbital calculations or high energy physics.
|
|
|
|
|
Flaviu2 wrote: Yes, but I don't know always how many decimal exist ...
This is how many decimals exist when storing the value into a float: 1E300000
If we encode that value into html: ∞
Best Wishes,
-David Delaune
|
|
|
|
|
Darkman's SWFLIB v1.1, release date - July 4, 2006 and he said "the future releases will increase the functionality of this library", see:
http://www.codeproject.com/KB/audio-video/SWFLIB.aspx?display=PrintAll
But i can't find any new messages about SWFLIB v1.2 or higher, do you know where we can get it or get a replacement lib?
|
|
|
|
|
SimonCommon wrote: do you know where we can get it or get a replacement lib?
Nope, because the best way to obtain such a info is posting the request at the article's own thread.
Veni, vidi, vici.
|
|
|
|
|
I want to navigate to a web page (with IE) and close IE after that ... here is the code :
STARTUPINFO siStartupInfo;
PROCESS_INFORMATION piProcessInfo;
memset(&siStartupInfo, 0, sizeof(siStartupInfo));
memset(&piProcessInfo, 0, sizeof(piProcessInfo));
siStartupInfo.cb = sizeof(siStartupInfo);
if(! CreateProcess(NULL,
_T("C:\\Program Files\\Internet Explorer\\iexplore.exe http://www.somepage.com"),
0,
0,
NULL,
CREATE_DEFAULT_ERROR_MODE,
0,
0,
&siStartupInfo,
&piProcessInfo))
{
CString sError;
sError.Format(_T("Create process error (%d)\n"),GetLastError());
SetWindowText(sError);
}
else
{
SetWindowText(_T("OK"));
WaitForSingleObject(piProcessInfo.hProcess,2000);
CloseHandle(piProcessInfo.hProcess);
CloseHandle(piProcessInfo.hThread);
}
the code from above open the web page ... but does not close IE after ... why ? What I'm doing wrong ?
|
|
|
|
|
From the platform SDK:
The CreateProcess function creates a new process, which runs independently of the creating process.
Thus, the new process terminates when you close it as any other process using the Exit menu item, close button, or pressing Alt-F4.
You may use the PROCESS_INFORMATION structure elements to identify the IE process and send it a termination message (e.g. by sending WM_CLOSE to the main window handle).
|
|
|
|
|
Thank you, I will work around ....
|
|
|
|
|
I saw that if I want to close an window, I need hWnd of that window ... but I don't know how can I get that if I have STARTUPINFO and PROCESS_INFORMATION structure ... none of this can achieve handle of new created window ... I'm pushing my luck ? Any hint will be very appreciated !
|
|
|
|
|
Have you tried:
PostThreadMessage(piProcessInfo.dwThreadId, WM_CLOSE, ...);
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
I'd like to ask what is probably a stupid question. Why would you "popup" a browser, have it navigate to a web page, only to close the browser.
Presumably you went to the page so that the user can see the output yet you want to take it down before knowing they've read it.
You want to tear down the process before knowing if the browser access to the web page even worked (network delays may cause the web page to not respond quickly) so if your URL is "transaction related", you never know if it worked or not.
You don't even know if the URL worked or if you got some browser message saying that the site was inaccessible.
Seems to me that you're using the wrong tool for the job, you might want to use the WinInet interface to read / write URLs programatically and process the output yourself.
Unless, of course, the web site is meant to display information to the user, in which case we're back to asking why tear it down before they get a chance to read it?
|
|
|
|
|
In fact, I want to execute an command to a some server :
www.somesite.com/index.php?command=12
and for that, would be proper to start IE browser in hidden mode ... perhaps I'm doing in worng way ??
|
|
|
|
|
Starting the browser is the wrong way. You can use the Wininet API to connect to the server.
There are some examples here at CP. I picked three from the search results:
CHttpClient - A Helper Class Using WinInet [^]
Simple HTTP Client using WININET [^]
AmHttpUtilities [^]
|
|
|
|
|
Yes, you are doing it the wrong way. You are just "firing and forgetting" when you use IE to do this, your program has no idea if it worked at all.
In addition to what Jochen said, the sequence of calls to the WinINet APIs that can simulate a POST operation is:
1) InternetOpen() to begin communication
2) InternetConnect() to connect to the web site
3) HttpOpenRequest() to do a POST to the script
4) HttpSendRequest() to send the data being "posted"
5) InternetReadFile() to receive any optional output the script produces (status)
6) InternetCloseHandle() to close the various handles opened by the previous steps.
You can look all these up on MSDN. Get this to work and you've learned a lot of useful stuff.
|
|
|
|
|
I want to execute this address :
// http://www.somesite.com/index.php?page=projects&sub=der_download_port
Here is my trial:
CString CTestWinInetDoc::SendRequest()
{
HINTERNET hSession = InternetOpen(_T("TestWinInet"),
INTERNET_OPEN_TYPE_DIRECT,NULL,NULL,0L);
if(hSession == NULL)return _T("Internet session handle invalid");
HINTERNET hConnect = InternetConnect(hSession,
_T("http://www.somesite.com"),
INTERNET_DEFAULT_HTTP_PORT,NULL,NULL,
INTERNET_SERVICE_HTTP,0,0);
if(hConnect == NULL)
{
InternetCloseHandle(hSession);
return _T("Internet connect handle invalid");
}
HINTERNET hRequest = HttpOpenRequest(hConnect, NULL,
_T("index.php?page=projects&sub=der_download_port"), NULL, NULL, 0, INTERNET_FLAG_RELOAD, 0);
if(hRequest == NULL)
{
InternetCloseHandle(hSession);
InternetCloseHandle(hConnect);
return _T("Internet request handle invalid");
}
BOOL bSent = HttpSendRequest(hRequest, NULL, 0,
NULL, 0);
if(! bSent)
{
InternetCloseHandle(hSession);
InternetCloseHandle(hConnect);
InternetCloseHandle(hRequest);
return _T("Can not sent requested data");
}
InternetCloseHandle(hSession);
InternetCloseHandle(hConnect);
InternetCloseHandle(hRequest);
return _T("Success !");
}
but this code seems to do nothing ... what is wrong here ?
|
|
|
|
|
Well, I don't do it that way. There are a number of curious things in your code.
First, you do an InternetSendRequest() with null pointers and 0 lengths. While that may be syntactically OK, I have no idea what you think that does nor why you are doing it.
2nd, you don't user InternerReadFile() to get the results of your attempts so if there were any error messages, you've discarded them. If you want to know what's wrong, those messages might have helped.
Third, your URL with parameters looks like a "Get" request (the default "verb" for HttpOpenRequest() is "GET") and I use this form mostly for "POST" requests. For "GET", I would use "InternetOpenURL()"
The sequence there would be
InternetOpen()
InternetOpenURL()
HttpQueryInfo()
InternetReadFile()
Don't throw away the output this time.
PS, did you check to see if the server received the request? Just how do you know it did nothing?
|
|
|
|
|
Hi Guys,
Is it possible to set TCP/IP timeout value per socket instance(connection)?
~ Vikram S
|
|
|
|
|
The actual socket timeout value is based on a configuration in the operating system. So the simple answer is no, there's really no convenient way to change timeout between socket instances.
|
|
|
|
|
Just went through this link. Correct me if my interpretation is wrong.
http://msdn.microsoft.com/en-us/library/windows/desktop/ee470551%28v=vs.85%29.aspx
|
|
|
|
|
My answer was based on the assumption you meant the connection timeout (the act of establishing a connection to another socket). If that's not what you meant, it doesn't apply.
|
|
|
|
|
okay. So If I have socket connection which is already established. Will I able to set a timeout so that TCP/IP implementation provided by OS, will automatically close it?
The reason for asking this question is I want to maintain a connection pool and want to make sure that if no one uses socket connections from it, it should get atomically freed.
~ Vikram S
|
|
|
|
|
Hi,
I have a replace function which replaces all the occurences of the string into another file. But when I use the replace function multiple times... it replaces the string which was passed in the last call only and all the previous replacement does not happen.
Below is the code
replace(char text2find[80],char text2repl[80])
{
char fileOrig[32] = "OrigFile.txt";
char fileRepl[32] = "ReplacedFile.txt";
char buffer[MAX_LEN_SINGLE_LINE+2];
char *buff_ptr, *find_ptr, *tok;
FILE *fp1, *fp2;
size_t find_len = strlen(text2find);
fp1 = fopen(fileOrig,"r");
fp2 = fopen(fileRepl,"w+");
while(fgets(buffer,MAX_LEN_SINGLE_LINE+2,fp1))
{
buff_ptr = buffer;
tok = strtok(buff_ptr,"*");
if(tok != NULL)
{
while ((find_ptr = strstr(buff_ptr,text2find)))
{
while(buff_ptr < find_ptr)
fputc((int)*buff_ptr++,fp2);
fputs(text2repl,fp2);
buff_ptr += find_len;
}
fputs(buff_ptr,fp2);
}
}
rewind(fp1);
rewind(fp2);
fclose(fp2);
fclose(fp1);
}
I wud actually wanto replace all the string in the same file, but am finding it tough and also reuse of the replace function multiple times wud be difficult. Hence went with two files...
Thanks,
Faez
|
|
|
|
|
Your file names are constant strings, defined inside your function. That is not the way to do it.
I see basically two ways that could work for you:
1.
perform all replace operations in memory, not in files. That way you can load a text file, modify the text as much as you want, then store the final text in the same or in another file.
2.
make the source and destination file names input parameters to your function, and use a new destination file name each time you call replace().
PS: why are you rewinding the files before closing them?
Luc Pattyn [My Articles] Nil Volentibus Arduum
Fed up by FireFox memory leaks I switched to Opera and now CP doesn't perform its paste magic, so links will not be offered. Sorry.
|
|
|
|
|
Faez Shingeri wrote: rewind(fp1);
rewind(fp2); These are unnecessary.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
I thought rewind will help me during the reuse of the file..
The replace function doesnot check for the entire string
I mean.. it replaces all the strings like &tabhostvars and &tabhostvars01 (I do not want this string to be replaced..) I only want &tabhostvars strings to be replaced
Can I do this..?? #vaguequestionButlearning
while ((find_ptr = strstr(buff_ptr,text2find)) && find_ptr+find_len+1 == NULL)
Thanks,
Faez
|
|
|
|
|