|
if you writing Socket Programs in Win32 Code,
you might have to develop multithread application for creation of Socket Server.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
Hi everybody.
I want to submit a web form. Source of html page:
<html>
<body>
<form action="i.php" method="post">
Name: <input type="text" name="fname" value="MyName" />
Age: <input type="text" name="age" value="17" />
<input type="submit" />
</form>
</body>
</html>
If I submit the form in the page above, I would get:
Welcome MyName!
You are 17 years old.
And this is my code:
CInternetSession session(L"MyAgent");
CHttpConnection* httpcon=session.GetHttpConnection(L"localhost");
CHttpFile* httpfile=httpcon->OpenRequest(CHttpConnection::HTTP_VERB_POST,L"i.php");
CString headers=L"Content-Type: application/x-www-form-urlencoded";
CString data=L"fname=MyName&age=17";
httpfile->SendRequest(headers,(LPVOID)(LPCTSTR)data,data.GetLength());
CString t=L"";
UINT len=100;
char buf[100];
while(len>0){
len=httpfile->Read(buf,100);
if(len>0)t.Append(CString(buf),len);
}
AfxMessageBox(t);
httpfile->Close();
httpcon->Close();
session.Close();
Unfortunately, form is not being submitted. What I'm doing wrong?
I'm trying to do this thing 3rd time now, I don't want to give up this time
Any help would be greatly appreciated.
modified on Thursday, August 27, 2009 6:28 PM
|
|
|
|
|
check your localhost port in the class CInternetSession.
it's my pleasure to make friend with you.
|
|
|
|
|
You probably need to set the Content-Length header.
If I were you, I'd download Fiddler[^] and use it to see what the difference is between the POST sent by the browser in response to that web form and the POST sent by your program.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Thanks Stuart Dootson!
I used Fiddler and looks like my program sending data in a different encoding.
Browser is sending:
fname=MyName
age=17
My program is sending:
f[]n[]a[]m[]e[]=[]M[]y[]N[]a[]m[]e
[]a[]g[]e=[]1[]7[]
(Meaning there is a square after each char)
What should I do to send like WebBrowser does?
|
|
|
|
|
Use ASCII rather than Unicode strings, I guess?
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Thank you again Stuart Dootson!
It worked
I used CStringA instead of CString.
But, what if I want to send Unicode string? I'll be sending data in russian too.
So is there way to send Unicode too?
|
|
|
|
|
Yes - you need to tell the system what encoding you're using. As far as I can see, that means adding an HTTP header OR something in the HTML document - this Wikipedia page[^] appears to have the details.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
I used Fiddler to see what is the browser sending when I typed unicode text.
Web Browser is converting the unicode text into hex values, like
%F2%E8 =ти (russian)
Let me post new thread for this is a different problem(Unicode to Hex conversion).
My problem in this thread is solved. Stuart Dootson, thank you so much!
|
|
|
|
|
Hi,
Created the application same as Windows firewall. In Windows Firewall Under Exception tab we have the "Add Program" button. On click of which the list of program is enumerated. I want to know from where this list is populated. Any registry key under which these programs are listed. or any method to get this list?
Regards.
"A winner is not one who never fails...but the one who never quits"
modified on Thursday, August 27, 2009 2:57 AM
|
|
|
|
|
I sorted through Registry Monitor several times and came up with nothing conclusive. There does not seem to be a registry key/value dedicated to such a list (that would be too easy), but rather a series of cross-referencing from several locations.
"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
|
|
|
|
|
thanks for the information.
I looked for NetFwMgr and tried to use the interfaces provided but was not able to get any thing.
INetFwMgr
NetFwPolicy
Thanks
"A winner is not one who never fails...but the one who never quits"
|
|
|
|
|
The INetFwAuthorizedApplications interface can be used to get the list of applications authorized to open ports in the firewall. This list will be smaller than the list that is shown when the "Add Program..." button is clicked.
Not having done this before, that's all I can offer.
"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
|
|
|
|
|
Thanx david.
I also tried with this... It makes sense if we display that list also. because firewall used add the programs in exception list and not displaying all the applications.
But then also need to find out how does windows get the list of application. I have VS6.0 intalled on my machine and firewall shows most of the application from Visual Studio 6.0 folder from the installed location.
Anyways...Will look to get....
Thanks again for the help.
"A winner is not one who never fails...but the one who never quits"
|
|
|
|
|
|
hello,
How can we get the proxy setting of a default web browser?
and How to apply these setting on IE?
Thanks...
|
|
|
|
|
I have a problem with this code
CString l_FilePath;
CFileDialog m_ldFile(TRUE,"txt","*.txt",OFN_ALLOWMULTISELECT | OFN_EXPLORER);
m_ldFile.m_ofn.lpstrFilter = "*.txt";
if (m_ldFile.DoModal() == IDOK)
{
POSITION temp = m_ldFile.GetStartPosition();
while(temp)
{
l_FilePath = m_ldFile.GetNextPathName(temp);
m_lstFiles.AddString(l_FilePath);
}
}
Now the problem. i have 8 files in a folder. when i select all the files and try to put the files in a listbox nothing is displaying. but when i am selecting only 7 files then the files are getting displayed. why is that so?
|
|
|
|
|
|
Hi Chandru,
Michael Schubert gave you a working solution but it may also fail if the buffer is too small. I like the solution offered by PJ Arends where you dont have to worry about the size of the buffer.
Multiple Selection in a File Dialog[^]
Its a really good technique.
Best Wishes,
-David Delaune
|
|
|
|
|
Much better solution indeed. My example was really just a suggestion to test whether it's a problem with the buffer being too small.
|
|
|
|
|
Can we use CoCreateInstance if the CLSID is not present . Can we use only dll name to create the object.
|
|
|
|
|
Why do want to call CoCreateInstancewithout CLSID?
I cannot understand your need.
Величие не Бога может быть недооценена.
|
|
|
|
|
Nope.
Possibly CLSIDFromProgID [^] maybe of interest for you.
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]
|
|
|
|
|
No. The DLL could contain more than one different type of object...
The easiest way to use a COM DLL given just the DLL is to use #import. That will bring in all the definitions you need without having to know or do anything else. Have a look at this answer[^] I just gave in the COM forum (which coincidentally is where this question should have been posted...).
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hi,
How can I set application icon (left top of the window) to my property sheet?
|
|
|
|