Thanks for your answer! I apologize for my mistake ...
I've done all everything you said and actually decrease errors. However there are still 5 errors relating some wrong commands. For example, some of errors are:
"The type or name 'Stream' could not be found (are you missing a using directive or an assembly reference?)"
"The type or name 'Bitmap' could not be found (are you missing a using directive or an assembly reference?)"
"The type or name 'MemoryStream' could not be found (are you missing a using directive or an assembly reference?)"
Eventually was missing the command using System.IO;
So the following 2 errors are gone
"The type or name 'Stream' could not be found (are you missing a using directive or an assembly reference?)".
"The type or name 'MemoryStream' could not be found (are you missing a using directive or an assembly reference?)".
I am coming again to the thread to asked you a little help.
I have make all necessary changes and now my program is running without any errors or warnings. But i can not see the image! Specifically I created a form with a button and a pictureBox. I want when I click the button to save the image and display it in the pictureBox.
Why cannot display the image? Here is my example:
privatevoid button1_Click(object sender, EventArgs e)
string sourceURL = "http://192.168.1.xxx:xx/videostream.cgi";
byte buffer = new byte;
int read, total = 0;
// create HTTP request
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(sourceURL);
// set login and password
req.Credentials = new NetworkCredential("Admin", "xxxx");
// get response
WebResponse resp = req.GetResponse();
// get response stream
Stream stream = resp.GetResponseStream();
// read data from streamint bytesToRead = 1000;
while ((read = stream.Read(buffer, total, bytesToRead)) != 0)
total += read;
bytesToRead -= read;
// get bitmap
Bitmap bmp = (Bitmap)Bitmap.FromStream(stream);
// Save Image
// Show image
pictureBox1.Image = bmp;
privatevoid pictureBox1_Click(object sender, EventArgs e)
What type of object is pictureBox1 and are you sure that the statement pictureBox1.Image = bmp; sets the object correctly? Note that the bmp object gets destroyed as soon as the button1_Click() function terminates.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
While it's not a solution to your question, I'd like to point something out.
Any network address that begins with 192.168 is an address in a private network. What this means is that, only computers in that network may access other devices within it.
As such, it's entirely safe for me to say that the IP of the machine I'm typing on right now is 192.168.43.156, and that the address of my gateway (the 'side' of the router that my pc can see) is 192.168.43.1
If I browse to a 'WhatsMyIp' type of website, the address returned is the IP that the 'other side' of my router has - the address that CAN be seen from anyone connected to the web. This address is NOT safe to share publicly.
Look, when two asynchronous processes are communicating things can go wrong at any moment. Even if there was a great way for you to check to see if the socket is in a good state, 1/2 microsecond later it could go bad so you'd still have to handle the "bad state" case when you access the socket connection. Just because it was in a good state an instant ago doesn't mean it still is, that's the nature of asynchronous communications and networks.
The falicy is expecting orderly things to happen in a disorderly world. Better to concentrate your efforts in dealing with the "error conditions", trying to communicate with the socket and discovering it's in a "bad state" by handling the failure returns, timeouts, etc. Handle the "disorderly shutdown" cases and you'll discover that the "orderly shutdown" cases fall out nicely.
I have 3 buttons on a dialod with tab stop property = false, sometimes if I click all buttons in random order a hover effect (round blue) comes around the 2 buttons simultaneouly. It don't disappear even after mouse is not on any button. I think It should not come. Can you please suggest any workaround?
Never seen or heard this behaviour described before. It does sound very strange. I just tried a win32 dialog-based project (compiled and run under win7 x64 home premium) yet was still unable to replicate this behaviour.
Can you show the DialogProc that you are using? Mine is below. (I have 5 buttons, only respond to the clicking of two of them)
BOOL CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
* TODO: Add code to initialize the dialog.
* TODO: Add more control ID's, when needed.
MessageBox(hwndDlg, "You clicked \"Test\" button!", "Information", MB_ICONINFORMATION);
Using WinInet -
I tried to send some data to login a website.But its server need to check my cookie at the same time.If the cookie is not match,this login action will be faild.I called the CHttpFile::AddRequest to add my cookie into the http header,than called CHttpFile::SendRequest.But the server return an error message.I holded this msg to google.Someone said this meens to your cookie in error.An internet friend said can not add in cookie into header to send,but use the CInternetSession::SetCookie.
SetCookie?How to use it?Or in other way can help me?
PS:I am a Chinese.My English is not well.But I need your help.Thank!
Without downloading other pre-fabricated programs that does this, or trying to reverse engineer other programs,
What would you recommend that I connect to just to get going at a beginners level. Perhaps a web service that returns the current version, or just a text file that contains the current version, and what information should I return?
If it's a text file, what recommended format would you suggest?
I'm looking for a way to resolve a URL to an IP Address, for this part of my winsock. I don't want to hard code it, because inside my LAN, I use private numbers, and outside my LAN is public numbers.
I would use a text file with a specific format (eg XML). The content depends on your requirements. Useful information are version, date, and URL of the update archive/executable file (so it can be stored on another host).
To resolve a host name to an IP address, use the Winsock function getaddrinfo [^].