|
Hi there,
I use MFC classes for doing a data transfer with Wininet. I need to authorize me on a server: apache/1.3.27 Ben-SSL/1.48 (Unix). It needs client certification and when done correct my client app. receives a session cookie to work with. Now my problem is, for the first request I can send the client ca and the authorisation works well. But when I want to do the next request, the send request from wininet throws an internet exception and askes for the client ca again. But this time there is no cookie in the response header as the first time. So I am not quiet sure if the problem is with the client ca or the cookie. In the IE6 I have all cookies enabled. I have not found yet a way to display the protocol header of my request.
Hope somebody can help me. Below I add some code sequences to make my problem clearer.
BOOL CWinInetTransfer::DoHttpRequest (...)
{
// If Internet Session is not already established try to create it.
if (!m_pISession)
{
m_pISession = new CInternetSession ("MyUserAgent", 1, INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
}
csPage.Empty();
csErrMsg.Empty();
int nVerb (CHttpConnection::HTTP_VERB_GET); // default. used to specify Method.
CString csRequestUrl;
CString csServer;
CString csObject;
DWORD dwServiceType(0);
INTERNET_PORT nPort(0); // defines port: 80 for normal HTTP, 443 for HTTPS
// always get method is used: Url + ? + Data to send.
csRequestUrl += _T("?");
csRequestUrl += csPostData;
// Parsing Url to get Server, Object and Port.
BOOL bParseUrl = AfxParseURL(csRequestUrl, dwServiceType, csServer, csObject, nPort);
UINT nbrChar;
DWORD dwRes;
CHttpConnection *pServer = NULL;
CHttpFile *pHttpFile = NULL;
try
{
pServer = m_pISession->GetHttpConnection((const char*)csServer, // pstrServer.
INTERNET_SERVICE_HTTP, // dwflags
nPort, NULL, NULL);
DWORD dwFlags (INTERNET_FLAG_NO_CACHE_WRITE | INTERNET_FLAG_RELOAD | INTERNET_FLAG_EXISTING_CONNECT);
if (nPort==INTERNET_DEFAULT_HTTPS_PORT)
{
//we are talking secure https
dwFlags |= INTERNET_FLAG_SECURE |
INTERNET_FLAG_IGNORE_CERT_CN_INVALID |
INTERNET_FLAG_IGNORE_CERT_DATE_INVALID;
}
if(pServer)
{
pHttpFile = pServer->OpenRequest(nVerb, (const char*)csObject, NULL, 1, NULL, NULL, dwFlags);
}
BOOL bSendRequestOk = FALSE;
DWORD dwReqStatusCode(0);
for(int i=0; i < 10; i++) // stop after then tries.
{
csErrMsg.Empty();
try
{
// Do Send Request
if (nTxMethod == CHttpConnection::HTTP_VERB_GET)
{
// used get Method.
bSendRequestOk = m_pHttpRequest->SendRequest();
}
// Test Send Request.
if (!bSendRequestOk)
{
return FALSE;
}
m_pHttpRequest->QueryInfoStatusCode(dwReqStatus);
if(dwReqStatus < 300)
{
// Transfer was successful.
break; // end for loop.
}
} // end try: Send Request.
catch (CInternetException* e)
{
// Error during Send request: Wininet throws Exception: exp: Client CA needed.
// Get Error Code from Exception
dwReqStatus = e->m_dwError; // Error Code.
e->Delete();
// Shows Dialog specialised for error code. This Dialog gets Client CA from system store if needed.
DWORD dwAnswer = m_pHttpRequest->ErrorDlg(pParentWnd, dwReqStatus,
FLAGS_ERROR_UI_FILTER_FOR_ERRORS |
FLAGS_ERROR_UI_FLAGS_GENERATE_DATA |
FLAGS_ERROR_UI_FLAGS_CHANGE_OPTIONS, NULL);
if (dwAnswer == ERROR_CANCELLED)
{
// Abbruch durch den Benutzer.
return FALSE;
}
} // end catch: IE Exception
} // next for loop if needed.
// Send Request finished. Now verify status code. < 300 success, > 300 error.
if (dwReqStatus < 300)
{
// successful. Read is done later.
return TRUE;
}
else
{
// Error occured.
return FALSE;
}
}
|
|
|
|
|
Hi!
I need help with getting the time in
hour:min:sec:microseconds.
I'm using struct tm to get hour:min:sec(no problem)and I use the struct timeval and timespec to get microseconds, but I am doing something wrong.
Does anyone know how to do?
|
|
|
|
|
Look at a class called: http://www.capecod.net/~pbaum/date/date0.htm
It has some good work on ms.
Best Wishes and Happy Holiday's,
ez_way
|
|
|
|
|
Hi Martin!
My browser can't find the webpage
|
|
|
|
|
OK
download it from my website in 15 minutes.
http://www.digitaltcp.com/downloads/DateClass_demo.zip
Best Wishes and Happy Holiday's,
ez_way
|
|
|
|
|
HI ,
Could any one tell me if it is possible to remove the Client area and view only the non-client area in an application (single doc type),
Anand
|
|
|
|
|
simplely resize the window, such that client area is not visiable
The World is getting smaller and so are the people.
|
|
|
|
|
In visual c++, how to add the button on the message box example ok button, cancle button and abort button.....
|
|
|
|
|
Pls try with the below code, Its way u have to use the buttons
MessageBox("Please Confirm Exit !! ","Exit Application",MB_SYSTEMMODAL+MB_ICONQUESTION+MB_YESNO)==IDYES)
NRVSundar
NRVSundar
|
|
|
|
|
Hi there
I have created a simple "Hello World" Win32 Application (No MFC!)
I want to remove the title bar.
I have tried using the style "WS_DLGFRAME" in create window but still i get a Title bar
Can somone help me remove the tile bar from my window.
Thanx in Advance
modified 21-Apr-21 21:01pm.
|
|
|
|
|
WS_CAPTION style defines whether your window has a title bar or not. If you remove this style from the style definition flags used with 'CreateWindow' call, the window will not have a title bar.
Remember, that the system menu flag (WS_SYSMENU) is dependant on the WS_CAPTION flag. Having the first without the latter may cause an assertion.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
Thanx for ur reply.
By the time i recieved ur reply i had already solved the problem
I have used WS_POPUP|WS_VISIBLE style and the thing is solved
modified 21-Apr-21 21:01pm.
|
|
|
|
|
Hi,
I used CFile object.I included afx.h as header.I am getting the following error in calling the function CallWindowProc and SetWindowLong .I did not include windows.h because I am getting error if I include both windows.h and afx.h
d:\test_plugins\gen_minisdk\trayctl.cpp(144) : error C2664: 'CallWindowProcA' : cannot convert parameter 1 from 'void *' to 'long (__stdcall *)(struct HWND__ *,unsigned int,unsigned int,long)'
Conversion from 'void*' to pointer to non-'void' requires an explicit cast
d:\test_plugins\gen_minisdk\trayctl.cpp(169) : error C2664: 'SetWindowLongA' : cannot convert parameter 3 from 'long (__stdcall *)(struct HWND__ *,unsigned int,unsigned int,long)' to 'long'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
Karteek
|
|
|
|
|
Explain your steps in more detail. The errors you posted and the CFile object are not related in any way.
If you are trying to use MFC without the project wizards, then in addition to including the afx.h header, you must link with the appropriate MFC library.
If you are trying to create a Winamp plugin, like it seems, then remember that in the XP world, you cannot subclass a window by replacing window procedures anymore. At least so it says in the MSDN.
The example provided by NullSoft may no longer function properly. I suggest you either contact them or spend some time experimenting. However, what I do know, like I stated, is that these errors have nothing to do with the CFile object. They might pop up because of the MFC header, but in that case, you'll just need to re-check your function calls and remember the linkages.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
I have an application where I need to have a grid, or something similar to an Excel spreadsheet. I inserted the Microsoft Spreadsheet 9.0 into my application, and I think I can make this do what I need it to if I knew how to control this thing. Has anybody used this before, or know of some good publications that I can figure out how to control it.
For example, I want to be able to set the column widths, and variable types...I'd even like to be able to make some columns read-only if possible. I'm just not figuring this out by looking at the function lists.
Thank you for your help.
I have never failed when programming. Instead I have succeeded in finding thousands of ways of crashing a computer!
Douglas A. Wright
dawrigh3@kent.edu
|
|
|
|
|
i wish to run my .exe program in a pc that unfortunately is nt installed with visual c++ so is there anyway i can get it run?
|
|
|
|
|
For that you need to make a installer for yuor application, and install all the neccessary dlls that ur applications requires. To find out that use depends.exe to determine on what all dlls ur application depends on.
The World is getting smaller and so are the people.
|
|
|
|
|
Hello
Please run the dependency walker under Ms VC Tools
If you do not have it search the microsoft website and I "think" you may download one from there.
Most VC functions may be installed in one component.
You may download this from http://sourceforge.net/project/showfiles.php?group_id=21558
It is at the very bottom of the page. Take extreme care (check for os before you install them.) can really screw xp 2000 and some other editions up.
Shold only be needed in NT 4. NT3. 95 some editions of 98. Every time you have to bloat your install files say "THANKS BILL" really loud.
Best Wishes and Happy Holiday's,
ez_way
|
|
|
|
|
Hi
I want to copy the contents of a CString into a WCHAR array:
WCHAR m_wszTitle[51];
How can i do this ?
|
|
|
|
|
wcscpy(m_wszTitle, CT2CW(strCString), 51)
--
Talk to the hand!
|
|
|
|
|
I get :
'CT2CW' : undeclared identifier !!!
i use vc++6.0
i also can't find CT2CW in the MSDN
|
|
|
|
|
|
Try:
USES_CONVERSION
wcscpy(m_wszTitle, CT2CW(strCString), 51)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.santacruznetworks.com">Santa Cruz Networks</A>
|
|
|
|
|
Ah yes. The ATL3 macros. :shudder:
--
Talk to the hand!
|
|
|
|
|
i used wcscpy(m_wszTitle, A2W(m_strDlgTitle));
it worked !!
i also had to include atlconv.h
|
|
|
|