|
|
Thanks for the links. I allready gone through the links and found solution.
It should as follows....
HINTERNET hOpenHandle, hConnectHandle, hResourceHandle;WORD dwError, dwErrorCode;
hOpenHandle = InternetOpen(NULL,INTERNET_OPEN_TYPE_PROXY, _T("192.168.9.10:8080"), NULL, INTERNET_FLAG_SECURE);
// _T("192.168.9.10:8080") is proxy with port number
DWORD dwServiceType = AFX_INET_SERVICE_HTTP;
CString szServer, szObject;
INTERNET_PORT nPort;
AfxParseURL (strURL, dwServiceType, szServer, szObject, nPort);
// strURL is any URL whose data to retrieve say http://www.google.com
hConnectHandle = InternetConnect(hOpenHandle,szServer,INTERNET_INVALID_PORT_NUMBER,
_T("test1"), _T("test"), INTERNET_SERVICE_HTTP, 0, 0);
// _T("test1"), _T("test") is username and password for proxy at my server
hResourceHandle = HttpOpenRequest(hConnectHandle, _T("GET"), szObject, NULL, NULL, NULL,
INTERNET_FLAG_KEEP_CONNECTION, 0);
resend:
HttpSendRequest(hResourceHandle, NULL, 0, NULL, 0);
DWORD dwStatus;
DWORD dwStatusSize = sizeof(dwStatus);
HttpQueryInfo(hResourceHandle, HTTP_QUERY_FLAG_NUMBER |
HTTP_QUERY_STATUS_CODE, &dwStatus, &dwStatusSize, NULL);
dwErrorCode = hResourceHandle ? ERROR_SUCCESS : GetLastError();
dwError = InternetErrorDlg(this->GetSafeHwnd(), hResourceHandle, dwErrorCode,
FLAGS_ERROR_UI_FILTER_FOR_ERRORS | FLAGS_ERROR_UI_FLAGS_CHANGE_OPTIONS | FLAGS_ERROR_UI_FLAGS_GENERATE_DATA, NULL);
if (dwError == ERROR_INTERNET_FORCE_RETRY)
goto resend;
DWORD dwNumberOfBytesRead;
char sz[1024];
int result;
do
{
result = InternetReadFile(hResourceHandle, sz, 1023, &dwNumberOfBytesRead);
sz[dwNumberOfBytesRead] = '\0';
int x = strlen(sz);
strResult += sz;
memset(sz, 0, 1024);
} while(result && dwNumberOfBytesRead != 0);
return strResult;
I was trying/searching this for two days and finally this is done. For others who want proxy authentication, can refer this code. But still there has to be a way by using CInternetSession as it is wrapper to WinInet API's used above. I am happy now that code is working fine now.
Thanks once again for your help.
|
|
|
|
|
In a dialog box application, a text box is placed on dialog and CString variable is used for text box.
To update data in text box i write some value in CSting variable and call UpdateData(False). But it gives assertion error in debug mode. No error in release mode. How to solve it.
There is a button on dialog box and onclick function for this button. In onclick function for button i call one function say disp. disp function display another dialog (call its DoModal()). When another dialog display i click on cancel button and it works fine.
I also call disp function from pretranslate message (for any key press). When disp function display another dialog and i click on cancel button an error occur (wincore.cpp). Why this error comming. How to avoid that
|
|
|
|
|
You could start by telling us which assert fails. What does it say?
|
|
|
|
|
I'll check what's error message and update here
|
|
|
|
|
MKC002 wrote: To update data in text box i write some value in CSting variable and call UpdateData(False). But it gives assertion error in debug mode. No error in release mode. How to solve it.
You could start by using a CEdit object instead (of CString ) and simply call its SetWindowText() method. Much cleaner and less prone to error.
"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
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
Yes but i am updating text on dialog box (on a static control) after some interval (say 10 secs). If i use SetWindowText then static control on dialog box flick.
While UpdateData(FALSE) does not flick.
No error in release mode.
|
|
|
|
|
MKC002 wrote: If i use SetWindowText then static control on dialog box flick.
Which indicates to me that you are doing something fundamentally wrong. Are you doing the update in a loop of some sort? Are other things happening at the same time?
"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
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
Not in a loop. I am updating only 1 time.
But i am doing from a thread.
I have dialog class pointer in thread class. From thread call i call a function of dialog class and pass string in that function which update data on static control.
dialog class function is like
dialogclass::func(TCHAR *str)
{
Staticstr = str;
UpdateData(FALSE);
}
where Staticstr is of cstring type and used for static control
|
|
|
|
|
MKC002 wrote: But i am doing from a thread.
Very bad idea to do that.
"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
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
Then which way i should select to display text on dialog
I am using thread to do some backend work which takes time and i need to update information on dialog so that user should be able to know what's going on
modified on Monday, October 18, 2010 5:59 AM
|
|
|
|
|
MKC002 wrote: Then which way i should select to display text on dialog...
Post a message from the secondary thread to the primary thread (the one that owns the UI).
"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
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
Hi,
How to get file creation date and time?
|
|
|
|
|
BOOL GetFileTime(
HANDLE hFile, // handle to file
LPFILETIME lpCreationTime, // creation time
LPFILETIME lpLastAccessTime, // last access time
LPFILETIME lpLastWriteTime // last write time
);
|
|
|
|
|
Please put your code within <pre></pre> tags as noted in the guidelines.
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
GetFileTime function.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Tis a real pity how people don't have MSDN or know how to google. But thanks to you they can breathe a sigh of relief...once again the day is saved....thanks to...CPallini
|
|
|
|
|
Yes, CPallini is a bot forwarding to Google...
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
|
I got the value in WIN32_FILE_ATTRIBUTE_DATA structure then how to format time like ""13/10/2010 2:51 PM"
code is
GET_FILEEX_INFO_LEVELS fiid;
WIN32_FILE_ATTRIBUTE_DATA fileinfo;
::GetFileAttributesEx(m_szFilePath,fiid,&fileinfo);
|
|
|
|
|
You can do it (at least) in two ways:
- Use the FileTimeToSystemTime Function (Windows)[^]: the
SYSTEMTIME structure that you get has separate fields for day, month,year, etc. and you have only to use printf or sprintf with an appropriate format string - Use the CTime Class (ATL/MFC)[^]: one of its constructors accept a reference to a
FILETIME structure. Then use the CTime::Format (ATL/MFC)[^] method, that returns a CString formatted accordingly to the specified format string
|
|
|
|
|
Hello, guys
CMFCRibbonBaseElement::SetVisible do not work....
But, I need this function.
How to hide the CMFCRibbonBaseElement????
Any help, or suggestion on where to look for help would be appreciated.
modified on Wednesday, October 13, 2010 3:45 AM
|
|
|
|
|
I never worked with the MFC version of the ribbon bar, only with the BCG version...but with that after making changes like that you would have to call RecalcLayout on the ribbon bar instance to make your changes take effect, maybe the MFC version has that too, give it a shot.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> "It doesn't work, fix it" does not qualify as a bug report. <
> Amazing what new features none of the programmers working on the project ever heard of you can learn about when reading what the marketing guys wrote about it. <
|
|
|
|
|
Hi,
Normally I can figure this stuff out, but not this one. I have just upgraded my program from VC6 to VS 2010. Quite a jump. It allows me to do things like actually debug now which is fantastic. Anyway, I have found a problem that I do not understand.
Basically there is a function (which I did not code originally) that is used to convert a hex string into a binary buffer.
ULONG util_ConvertHexStringToBin(char *pszHexString, void *pBinaryBuffer, unsigned int uiBufferSize)
{
unsigned int uiHexPairs;
unsigned int uiByteIndex;
char *pszParse = NULL;
BYTE ucTempByte;
uiHexPairs = strlen(pszHexString)/2;
pszParse = pszHexString;
uiByteIndex = 0;
while (uiByteIndex < uiBufferSize && uiByteIndex < uiHexPairs)
{
sscanf_s(pszParse, "%2x", &ucTempByte);
((BYTE *)pBinaryBuffer)[uiByteIndex] = ucTempByte;
pszParse += 2;
uiByteIndex++;
}
return uiByteIndex;
}
The problem is, as soon as sscanf_s is called, pszParse becomes invalid. I've seen other strange things too, like the uiByteIndex being reset to 0 when calling sscanf_s. I have tried sscanf as well with the same results.
The problem this is at the edge of my c++ knowledge. Its acting like the memory where these varables are stored is free and being overwritten, but this shouldn't be the case. I'm getting different results all the time with this function and this worries me a lot!
Any help, or suggestion on where to look for help would be appreciated.
|
|
|
|
|
What do you mean exactly by "pszParse becomes invalid" ? What is your program doing ?
|
|
|
|