|
I use in my program MFC to download files from the internet, and I want to know if it will work through an authenticating proxy server.
This is my CInternetSession object:
m_pInternetSession = new CInternetSession("Microsoft Internet Explorer 5.0");
And this is CInternetSession constructor from MFC sources.
#define PRE_CONFIG_INTERNET_ACCESS INTERNET_OPEN_TYPE_PRECONFIG
.................................
CInternetSession(LPCTSTR pstrAgent = NULL,
DWORD_PTR dwContext = 1,
DWORD dwAccessType = PRE_CONFIG_INTERNET_ACCESS,
LPCTSTR pstrProxyName = NULL,
LPCTSTR pstrProxyBypass = NULL,
DWORD dwFlags = 0);
So it uses INTERNET_OPEN_TYPE_PRECONFIG by default.
And this is written about INTERNET_OPEN_TYPE_PRECONFIG in MSDN:
Use INTERNET_OPEN_TYPE_PRECONFIG to instruct your application to retrieve the configuration from the registry
So does that mean that my program will correctly load any proxy settings that were set for internet explorer and how can I check that? I've never really used proxies, so I'm at a loss here.
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
Have you tried it to see if it does work or not?
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
How can I check if it works? I myself don't connect through a proxy, this issue happens with a client.
Is there any way I can use a public proxy to make a test?
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
sashoalm wrote: How can I check if it works? I myself don't connect through a proxy, this issue happens with a client.
Is there any way I can use a public proxy to make a test?
I think you can make Fiddler[^] act as a proxy that requires authentication. You could test it with that?
Fiddler's an incredibly useful tool to have anyway if you're doing lower-level web development, as you are - it's like Visual Studio's debugger, but for web traffic!
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Thanks for the link. I installed Fiddler, and I see that it has set my connection settings to use proxy at 127.0.0.1:8888, so it should be working. But I couldn't find any option to make it issue authentification challenges (I checked in Tools->Fiddler Options)
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
It might need scripting (if it's possible) - have a look at this page[^]
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Thanks for your help, it worked. I now get an auth. request when I start Internet Explorer, and I found where the problem with our app is. Btw it didn't need scripting, there was a menu entry "Rules->Require Proxy Authentification".
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
So there is!
Glad it worked for you!
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
As an alternative to Fiddler, Squid[^] is a well-respected web proxy that (may be) easy to install and configure. It supports authentication (including HTTP Basic and Windows NTLM), so would probably make a good simulation of your customer's scenario (hey - they might use Squid, in which case you could use their configuration to guide you possibly?).
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
ok, so i have a dialog, which i'll call CMainDlg.
CMainDlg has a regular CSplitterWnd with two columns.
the splitter has two CWnd derived objects in it, which i'll call CNewWnd
so here's how i created them:
(inside CMainDlg's onInitDialog)
CCreateContext* con = new CCreateContext();<br />
con->m_pNewViewClass = RUNTIME_CLASS(CNewWnd);<br />
<br />
splitter.CreateStatic( this, 1, 2, WS_VISIBLE);<br />
splitter.CreateView(0,0, con->m_pNewViewClass, CSize(200, 200), con);<br />
splitter.CreateView(0,1, con->m_pNewViewClass, CSize(200, 200), con);
that creates the splitters, and the stuff inside them, everything works perfectly, except for the fact that i can't seem to catch the messages from the CNewWnd using ON_NOTIFY
so the problem is, ON_NOTIFY requires the DlgCtrlID like this:
ON_NOTIFY(NM_CLICK, IDD_DLG, func)
but i dont have that value cause the CNewWnd objects are created dynamically
i tried using SetDlgCtrlID() on the CNewWnd objects but it seems to crash the splitter
i also tried sending custom ids using SendMessage but it's not getting caught
(inside CMainDlg)
ON_NOTIFY(NM_CLICK, 15, func)<br />
splitter.GetPane(0, 0)->m_customid = 15;
(inside CNewWnd)
GetOwner->SendMessage(WM_NOTIFY, (WPARAM) m_customid, (LPARAM)hdr);
any suggestions? thanks
|
|
|
|
|
kitkat12012 wrote: i can't seem to catch the messages from the CNewWnd using ON_NOTIFY
so the problem is, ON_NOTIFY requires the DlgCtrlID like this:
ON_NOTIFY(NM_CLICK, IDD_DLG, func)
but i dont have that value cause the CNewWnd objects are created dynamically
It's been a while but I think you want to be notified of WM messages from a CView. NM messages are sent from specific controls.
See here[^]
|
|
|
|
|
When we compile a C/C++ program we get the object code.
Now my doubt is :
When the object code is executed after transferring into the main memory what is it :
1. Is it a PROGRAM or
2. IS it a process....
I got really confused today in my vivas today cause of my examiner....
|
|
|
|
|
A program in execution is called "Process". A program is what you call as .exe. That would also call as an application.
So Program, process, Application all would mean same.
lionelcyril wrote: When the object code is executed after transferring into the main memory what is it :
Also, You don't execute an object code. Your object code gets through linker to make it executable code. .exe
Starting to think people post kid pics in their profiles because that was the last time they were cute - Jeremy.
|
|
|
|
|
Another thing to add is that object code cannot be executed.
It has to be linked by a linker into an executable before it can be executed.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
Oops I was just adding it.
Starting to think people post kid pics in their profiles because that was the last time they were cute - Jeremy.
|
|
|
|
|
When you compile C/C++ sources, usually you obtain an executable (or an application): the object code (usually again) is just an intermediate result.
lionelcyril wrote: When the object code is executed after transferring into the main memory what is it :
1. Is it a PROGRAM or
2. IS it a process....
Is is a process , i.e. a running executable (or running application).
'Program', on the other hand, has a very broad sense, usually the context qualify better its meaning.
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]
|
|
|
|
|
Hi,
I am writing some code that can download JPEG images from the net (HTTP) and display them on my dialog app.
So far I am able to get the image with IStream interface by using IWinHttpRequest 's get_ResponseStream() . But I found myself failing to take the Stream object to load it to GDI+ Bitmap object.
IStream *pStream;
if (NULL != pStream)
{
Bitmap *pGdiBmp = NULL;
LARGE_INTEGER llMove;
llMove.LowPart = 0;
llMove.HighPart = 0;
pStream->Seek(llMove, STREAM_SEEK_SET, NULL);
pGdiBmp = Bitmap::FromStream(pStream);
}
pGdiBmp is always NULL . I tried to save pStream to disk and the resulted binary is correct JPEG file.
What am I doing wrong here?
Any help would be great.
Thanks in advance.
modified on Thursday, May 7, 2009 11:48 AM
|
|
|
|
|
I'd verify that the contents of the stream are a JPEG by loading it into memory using GetHGlobalFromStream followed by a GlobalLock on the HGLOBAL you got back from the first function. Then verify that the memory starts with the string "JFIF".
I used the WinHttp functions to download a JPG and found that the JPG started after the first six bytes of the response (I created a stream on a set of bytes) - I needed to offset the stream by six bytes to get the Bitmap to load:
Gdiplus::Bitmap* LoadBitmapFromUrl(CString const& url)
{
HINTERNET hInternet = WinHttpOpen(L"hello", WINHTTP_ACCESS_TYPE_DEFAULT_PROXY, WINHTTP_NO_PROXY_NAME, WINHTTP_NO_PROXY_BYPASS, 0);
if (!hInternet) return 0;
HINTERNET hConnection = WinHttpConnect(hInternet, L"www.python.org", INTERNET_DEFAULT_PORT, 0);
if (!hConnection) return 0;
LPCWSTR types[] = { L"image/jpeg", 0 };
HINTERNET hRequest = WinHttpOpenRequest(hConnection, L"GET", L"/images/success/standrews.jpg", 0, WINHTTP_NO_REFERER, types, 0);
if (!hRequest) return 0;
if (!WinHttpSendRequest(hRequest, WINHTTP_NO_ADDITIONAL_HEADERS, 0, WINHTTP_NO_REQUEST_DATA, 0, 0, 0)) return 0;
if (!WinHttpReceiveResponse(hRequest, 0)) return 0;
HGLOBAL gblBuffer = GlobalAlloc(0, 1<<20);
LPBYTE buffer = (LPBYTE)GlobalLock(gblBuffer);
DWORD nBytesRead;
if (!WinHttpReadData(hRequest, buffer, 1<<20, &nBytesRead)) return 0;
IStream* pStream = 0;
CreateStreamOnHGlobal(gblBuffer, FALSE, &pStream);
ULARGE_INTEGER size; size.QuadPart = nBytesRead;
pStream->SetSize(size);
LARGE_INTEGER offset; offset.QuadPart = 6;
pStream->Seek(offset, STREAM_SEEK_SET, 0);
return new Gdiplus::Bitmap(pStream, FALSE);
}
(Please ignore the memory leak - I couldn't be bothered to tidy up - it's not production code )
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Dear Stuart,
Thanks for the help. I'd get invalid image if I offset the stream by 6 bytes. I am not sure why it worked in your case.
Anyway, I found where my problem was. I have that code running outside of GDI+ library init scope. After I moved the following init code to CWinApp::InitInstance() , it worked fine.
Gdiplus::GdiplusStartupInput gdiplusStartupInput;
Gdiplus::GdiplusStartup(&m_gdiplusToken, &gdiplusStartupInput, NULL);
|
|
|
|
|
I took it as a given that the GDI+ stuff was right - more fool me
J.B. wrote: I'd get invalid image if I offset the stream by 6 bytes. I am not sure why it worked in your case.
Maybe because I was using WinHttpReadData rather than getting a stream directly from the IWinHttpRequest object.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Stuart Dootson wrote: Maybe because I was using WinHttpReadData rather than getting a stream directly from the IWinHttpRequest object.
That'd be strange, because I checked the my Stream buffer and it had the same pattern as you described - after first 6 bytes, it comes with "JFIF"
FF D8 FF E0 00 10 4A 46 49 46
J F I F
|
|
|
|
|
I'm wrong - I thought the JFIF came at the start of a JPEG file - having just looked at a JPG in a hex editor, it doesn't.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
trongduy wrote:
1. Be organized classes and write the application to allow load and display all kinds of image files with the extensions in the following categories. Jpg,. Bmp,. Dib,. Gif. Programs that change the image as horizontal turn, vertical (mirror), dial 90degree, the gray level to get the sound, get the wrong picture of the two special functions and stored into different (but still one of the significantly above).
Requirements: The thought by the audience. Can be programmed in the Windows environment. Do not use static function as eg in the theory, does not switch, in the case.
2. An "input directory" is a folder or a file, a directory of many "input folder". Drive is a special case of the directory. Be organized classes to perform concept computer, disk drive, folder, file with the relationship as over. Write the application for permission to view the content of the object type as similar functions of the software Tree NC.
3. For the types: circle, ellipse image, the polygon, crescent,'s wings, rhombus, parallelogram, trapezium, rectangle, square, triangle, triangle square, square triangle needed. Write a program that allows applications to create (or enter) the two pictures in one of the above. Notice in two pictures that are not intersecting, if any color to the bowl and the dark sea of the interface. The user can press the arrow keys to move one of two pictures, the +, - to zoom out one of the two pictures. Programs can work with all kinds of equipment in different graphics modes, text mode (each a '*' is a moral pixels). Program can zoom to pixel morally, from the graphics mode to text or vice versa, users do not see the object to be exhaustive or bé tí hon.
4. A road of many road Polyline (line), each line can be a straight section (Strait line), and (ARC), or a bezier polyline. Organization of classes necessary, establish the relationship between class and write a program that allows to create polyline, create a copy of the polyline, zoom in, zoom out, turn polyline, polyline separation (separation of the polyline in the a polyline into the road (line, arc, bezier), define two functions have polyline cross or not?
|
|
|
|
|
See here.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"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
|
|
|
|
|
Hi there,
I have in my application a button that launches another application such as the on-screen keyboard using the createprocess function. If the button is pressed again I want to close the application. How can I do this safely?
Many thanks
Jim
|
|
|
|
|