Question About C++ (getting info)
Is there anyway in c++ I can have the user input something like a sentence and then have that sentence sent to my email or something?

Artificial wrote:That would be very possible.
Eternal Darkness wrote:I hope this helps... Email Sender (C++).zip
(Source : YouTube - Visual C++ 2008: Advanced Email Sending Program)
cout<< "What do you think of this program?";
cin>>useranswer;
send to:ksrocks333@gmail.com;
ksrocks333 wrote:Thanks, but not exactly what I'm looking for. I still haven't learned how to make the windows applications with all the fancy stuff. I'm still just making console apps.
But, I'm not really looking for them to HAVE to put the email they want to send it to. More so just I ask them for a response and it sends it to my predetermined email of ksrocks333@gmail.com.
so like:
(i know this wouldn't work, that's why I'm asking how to do it)
cout<< "What do you think of this program?";
cin>>useranswer;
send to:ksrocks333@gmail.com;
There input could be a whole sentence, like: I thought the program was pretty good.
I don't want them to have to put my email in everytime. How would i do that?
Eternal Darkness wrote:Try this:
Sending E-Mail with System.Web.Mail - CodeGuru
I tried re-coding it but I have no Idea about what I am doing in C++... xD
ksrocks333 wrote:Woah, XD That seems a lot more complicated than it has to be. XDD I tried running just as it is, and it didn't work.
There has to be a simpler way. XD
I'm going to ask my C++ teacher on monday if I can't find an answer.
Eternal Darkness wrote:Thats the only one I could find from google... xD
Hope you find your answer...
I wouldn't be surprised if he doesn't know how to do it...
I know how to do it in VB... xD
ksrocks333 wrote:WELL LUCKY YOU. XDDDD
Yeah, he's really good with programming, took it all through college. I bet he'll know how. He's gonna be like: Uh, I know how, but we haven't learned any of it yet. and i'll have to beg him to teach it to me. XD
Yeah. I need to learn VB this summer. I think I'm sticking with my decision to keep with C++ until the class is over. I mean I'll continue with it, but I want to learn VB too.
Chad wrote:VB is for beginners. I suggest either C#.net or C++.net. Both have Easy GUI creators, you don't have to code the GUI's. I like C#.net because it's relatively simple and it's really powerful. It can get really hard at times.
The problem would be for you to learn a whole new syntax different from what you know in Dev C++
Edit: another problem would be (if you use C#.net) that the user would have to have .net framework 3.5 installed SP1.
Eternal Darkness wrote:But VB is easy to learn and code in... Making it a perfect learning program...
Plus then he can program Gaia Bots, with ease, like he really wants to do...
Then since he knows the program he can convert :
Convert VB.NET to C# - A free code conversion tool - developer Fusion - ASP.NET, C# Programming, VB.NET, .NET Framework, Java and Visual Basic Tutorials
ksrocks333 wrote:*she, I'm a girl. XD
But isn't C++ different from C#?
If so, wont that converter not work?
Chad wrote:C# is totally different from C++. Tried it.
Converters are shit. Why?
because they just change {} then, if, else, for, do, while, etc etc statements and other things into there equivalents. Nothing big.
Edit:
@ED; if She really wants to make Gaia bots she can simply (if she is good enough) to either make her own http wrappers or use a different method. There is no need to change languages thus learn a new one.
Eternal Darkness wrote:I am talking about learning VB then converting to C# if you decide to program in that...
VB is easier to learn & code in so I suggest you learn that first...
Sorry, I for calling you a he instead of a she... I will fix it...
The converter works for me...
Yes she could, or she could learn VB... It's not like its that complicated (The base of the language anyway)... She is just starting out C++ anyway...
rk for you then convert the vb.net wrappers into C#.net and try using them. Do eeeet.Chad wrote:If they drk for you then convert the vb.net wrappers into C#.net and try using them. Do eeeet.
-- line 1 col 1: Not supported in C#: OptionDeclaration -- line 0 col 0: Optional parameters aren't supported in C# -- line 0 col 0: Optional parameters aren't supported in C# -- line 0 col 0: Optional parameters aren't supported in C# -- line 0 col 0: Optional parameters aren't supported in C# -- line 0 col 0: Optional parameters aren't supported in C# -- line 0 col 0: Optional parameters aren't supported in C# -- line 0 col 0: Optional parameters aren't supported in C# -- line 0 col 0: Optional parameters aren't supported in C# -- line 0 col 0: Optional parameters aren't supported in C# -- line 0 col 0: Optional parameters aren't supported in C# -- line 250 col 9: Not supported in C#: OnErrorStatement -- line 262 col 9: Not supported in C#: ReDimStatement -- line 0 col 0: Optional parameters aren't supported in C# -- line 309 col 9: Not supported in C#: OnErrorStatement -- line 332 col 9: Not supported in C#: ReDimStatement -- line 346 col 5: Handles clauses are not supported in C# -- line 353 col 5: Handles clauses are not supported in C# -- line 359 col 5: Handles clauses are not supported in C# -- line 369 col 5: Handles clauses are not supported in C# -- line 375 col 5: Handles clauses are not supported in C# -- line 376 col 9: Not supported in C#: OnErrorStatement -- line 387 col 9: Not supported in C#: OnErrorStatement -- line 466 col 9: Not supported in C#: ReDimStatement -- line 474 col 9: Not supported in C#: ReDimStatement
// ERROR: Not supported in C#: OptionDeclaration
using VB = Microsoft.VisualBasic;
public class HTTPWrapper : System.Windows.Forms.ContainerControl
{
* *
* * tData[] Cookies;
* *
* * public bool StopIT;
* * public bool DontParseHttp;
* *
* * public string LastPage;
* *
* * public short UBoundCookies;
* *
* * string strKomplett;
* * string strINC;
* *
* * const string HTTPRequest = "%Action n File%" + Constants.vbCrLf + "Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*" + Constants.vbCrLf + "%Referer%" + "Accept-Language: en-us" + Constants.vbCrLf + "Content-Type: application/x-www-form-urlencoded" + Constants.vbCrLf + "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows 98)" + Constants.vbCrLf + "Host: %Host%" + Constants.vbCrLf + "%Content-Length%" + "Connection: Close" + Constants.vbCrLf + "%Cookies%" + Constants.vbCrLf + "%Data%";
* *
* * //"Accept-Encoding: gzip, deflate"
* *
* * public event CookieUpdateEventHandler CookieUpdate;
* * public delegate void CookieUpdateEventHandler(System.Object Sender, CookieUpdateEventArgs e);
* *
* * private string FormPOST(ref string File, ref string Host, ref string Data, [System.Runtime.InteropServices.OptionalAttribute, System.Runtime.InteropServices.DefaultParameterValueAttribute("")] ref // ERROR: Optional parameters aren't supported in C#
string Referer)
* * {
* * * *
* * * * string tmpVar = null;
* * * *
* * * * tmpVar = Strings.Replace(HTTPRequest, "%Action n File%", "POST " + File + " HTTP/1.1");
* * * * tmpVar = Strings.Replace(tmpVar, "%Referer%", Referer);
* * * * tmpVar = Strings.Replace(tmpVar, "%Host%", Host);
* * * * tmpVar = Strings.Replace(tmpVar, "%Content-Length%", "Content-Length: " + Strings.Len(Data) + Constants.vbCrLf);
* * * * tmpVar = Strings.Replace(tmpVar, "%Cookies%", BuildHttpCookies(Cookies));
* * * * tmpVar = Strings.Replace(tmpVar, "%Data%", Data);
* * * *
* * * * * *
* * * * return tmpVar;
* * }
* *
* * private string GETPage(ref string File, ref string Host, [System.Runtime.InteropServices.OptionalAttribute, System.Runtime.InteropServices.DefaultParameterValueAttribute("")] ref // ERROR: Optional parameters aren't supported in C#
string Referer)
* * {
* * * *
* * * * string tmpVar = null;
* * * *
* * * * tmpVar = Strings.Replace(HTTPRequest, "%Action n File%", "GET " + File + " HTTP/1.1");
* * * * tmpVar = Strings.Replace(tmpVar, "%Referer%", Referer);
* * * * tmpVar = Strings.Replace(tmpVar, "%Host%", Host);
* * * * tmpVar = Strings.Replace(tmpVar, "%Content-Length%", "");
* * * * tmpVar = Strings.Replace(tmpVar, "%Cookies%", BuildHttpCookies(Cookies));
* * * * tmpVar = Strings.Replace(tmpVar, "%Data%", "");
* * * *
* * * * * *
* * * * return tmpVar;
* * }
* *
* * public string GetImage(ref string Image, [System.Runtime.InteropServices.OptionalAttribute, System.Runtime.InteropServices.DefaultParameterValueAttribute("")] ref // ERROR: Optional parameters aren't supported in C#
string ProxyServer, [System.Runtime.InteropServices.OptionalAttribute, System.Runtime.InteropServices.DefaultParameterValueAttribute(80)] ref // ERROR: Optional parameters aren't supported in C#
int ProxyPort)
* * {
* * * * if (string.IsNullOrEmpty(ProxyServer)) {
* * * * * * GetImage = GetWrapper(Image);
* * * * }
* * * * else {
* * * * * * GetImage = GetWrapper(Image, , ProxyServer, ProxyPort);
* * * * }
* * * *
* * * * * *
* * * * return Strings.Mid(GetImage, Strings.InStr(1, GetImage, Constants.vbCrLf + Constants.vbCrLf) + 4);
* * }
* *
* * public string GetWrapper(ref string URL, [System.Runtime.InteropServices.OptionalAttribute, System.Runtime.InteropServices.DefaultParameterValueAttribute("")] ref // ERROR: Optional parameters aren't supported in C#
string Referer, [System.Runtime.InteropServices.OptionalAttribute, System.Runtime.InteropServices.DefaultParameterValueAttribute("")] ref // ERROR: Optional parameters aren't supported in C#
string ProxyServer, [System.Runtime.InteropServices.OptionalAttribute, System.Runtime.InteropServices.DefaultParameterValueAttribute(80)] ref // ERROR: Optional parameters aren't supported in C#
int ProxyPort)
* * {
* * * *
* * * * string functionReturnValue = null;
* * * * string TempRef = null;
* * * * string HostX = null;
* * * * string Tempfile = null;
* * * * string FileX = null;
* * * *
* * * * if (!string.IsNullOrEmpty(Referer)) {
* * * * * * TempRef = "Referer: " + Referer + Constants.vbCrLf;
* * * * }
* * * * else {
* * * * * * TempRef = "";
* * * * }
* * * *
* * * * WaitForWinSockClose();
* * * *
* * * * if (Strings.LCase(VB.Left(URL, 7)) == "http://") {
* * * * * * Tempfile = Strings.Mid(URL, 8);
* * * * }
* * * * else {
* * * * * * Tempfile = URL;
* * * * }
* * * *
* * * * if (string.IsNullOrEmpty(ProxyServer)) {
* * * * * * HostX = VB.Left(Tempfile, Strings.InStr(1, Tempfile, "/") - 1);
* * * * }
* * * * else {
* * * * * * HostX = ProxyServer;
* * * * }
* * * *
* * * * if (string.IsNullOrEmpty(ProxyServer)) {
* * * * * * FileX = Strings.Mid(Tempfile, Strings.InStr(1, Tempfile, "/"));
* * * * }
* * * * else {
* * * * * * FileX = URL;
* * * * }
* * * *
* * * * if (Winsock1.CtlState != 0) {
* * * * * * Winsock1.Close();
* * * * * * WaitForWinSockClose();
* * * * }
* * * *
* * * * Winsock1.RemoteHost = HostX;
* * * * Winsock1.RemotePort = ProxyPort;
* * * * Winsock1.LocalPort = 0;
* * * *
* * * * if (!StopIT & Winsock1.CtlState != 7) {
* * * * * * Winsock1.Connect();
* * * * }
* * * *
* * * * WaitForWinSockConnect();
* * * *
* * * * if (!StopIT) {
* * * * * * Winsock1.SendData(GETPage(FileX, HostX, TempRef));
* * * * }
* * * *
* * * * WaitForWinSockClose();
* * * *
* * * * LastPage = URL;
* * * * if (Strings.LCase(VB.Left(URL, 7)) != "http://") {
* * * * * * LastPage = "http://" + LastPage;
* * * * }
* * * *
* * * * if (DontParseHttp) {
* * * * * * functionReturnValue = strKomplett;
* * * * }
* * * * else {
* * * * * * functionReturnValue = HTTParse(strKomplett);
* * * * }
* * * * * *
* * * * return functionReturnValue;
* * }
* *
* * public string PostWrapper(ref string URL, ref string Datastring, [System.Runtime.InteropServices.OptionalAttribute, System.Runtime.InteropServices.DefaultParameterValueAttribute("")] ref // ERROR: Optional parameters aren't supported in C#
string Referer, [System.Runtime.InteropServices.OptionalAttribute, System.Runtime.InteropServices.DefaultParameterValueAttribute("")] ref // ERROR: Optional parameters aren't supported in C#
string ProxyServer, [System.Runtime.InteropServices.OptionalAttribute, System.Runtime.InteropServices.DefaultParameterValueAttribute(80)] ref // ERROR: Optional parameters aren't supported in C#
int ProxyPort)
* * {
* * * *
* * * * string functionReturnValue = null;
* * * * string TempRef = null;
* * * * string HostX = null;
* * * * string Tempfile = null;
* * * * string FileX = null;
* * * *
* * * * if (!string.IsNullOrEmpty(Referer)) {
* * * * * * TempRef = "Referer: " + Referer + Constants.vbCrLf;
* * * * }
* * * * else {
* * * * * * TempRef = "";
* * * * }
* * * *
* * * * if (Strings.LCase(VB.Left(URL, 7)) == "http://") {
* * * * * * Tempfile = Strings.Mid(URL, 8);
* * * * }
* * * * else {
* * * * * * Tempfile = URL;
* * * * }
* * * *
* * * * if (string.IsNullOrEmpty(ProxyServer)) {
* * * * * * HostX = VB.Left(Tempfile, Strings.InStr(1, Tempfile, "/") - 1);
* * * * }
* * * * else {
* * * * * * HostX = ProxyServer;
* * * * }
* * * *
* * * * if (string.IsNullOrEmpty(ProxyServer)) {
* * * * * * FileX = Strings.Mid(Tempfile, Strings.InStr(1, Tempfile, "/"));
* * * * }
* * * * else {
* * * * * * FileX = URL;
* * * * }
* * * *
* * * * if (Winsock1.CtlState != 0) {
* * * * * * Winsock1.Close();
* * * * * * WaitForWinSockClose();
* * * * }
* * * *
* * * * Winsock1.RemoteHost = HostX;
* * * * Winsock1.RemotePort = ProxyPort;
* * * * Winsock1.LocalPort = 0;
* * * *
* * * * if (!StopIT & Winsock1.CtlState != 7) {
* * * * * * Winsock1.Connect();
* * * * }
* * * *
* * * * WaitForWinSockConnect();
* * * *
* * * * if (!StopIT) {
* * * * * * Winsock1.SendData(FormPOST(FileX, HostX, Datastring, TempRef));
* * * * }
* * * *
* * * * WaitForWinSockClose();
* * * *
* * * * LastPage = URL;
* * * * if (Strings.LCase(VB.Left(URL, 7)) != "http://") {
* * * * * * LastPage = "http://" + LastPage;
* * * * }
* * * *
* * * * if (DontParseHttp) {
* * * * * * functionReturnValue = strKomplett;
* * * * }
* * * * else {
* * * * * * functionReturnValue = HTTParse(strKomplett);
* * * * }
* * * * * *
* * * * return functionReturnValue;
* * }
* *
* * private string HTTParse(ref string ServerHttp)
* * {
* * * *
* * * * string functionReturnValue = null;
* * * * string HTTPHeader = "";
* * * * string HTTPBody = "";
* * * * string msg = null;
* * * * int Chunksize = 0;
* * * * int[] TN = new int[3];
* * * * //UPGRADE_WARNING: Lower bound of array TN was changed from 1 to 0.
* * * *
* * * * TN(1) = Strings.InStr(1, ServerHttp, Constants.vbCrLf + Constants.vbCrLf);
* * * * HTTPHeader = Strings.Mid(ServerHttp, 1, TN(1));
* * * * if (Strings.InStr(1, HTTPHeader, "Transfer-Encoding: chunked") != 0) {
* * * * * * msg = Strings.Mid(ServerHttp, TN(1) + 4);
* * * * * * TN(1) = Strings.InStr(1, msg, Constants.vbCrLf) - 1;
* * * * * * Chunksize = Dez(Strings.Mid(msg, 1, TN(1)));
* * * * * * TN(1) = TN(1) + 3;
* * * * * * while (!(Chunksize == 0)) {
* * * * * * * * HTTPBody = HTTPBody + Strings.Mid(msg, TN(1), Chunksize);
* * * * * * * * TN(1) = TN(1) + Chunksize + 2;
* * * * * * * * TN(2) = Strings.InStr(TN(1) + 1, msg, Constants.vbCrLf);
* * * * * * * * if (TN(2) == 0) break; // TODO: might not be correct. Was : Exit Do
* * * * * * * * Chunksize = Dez(Strings.Mid(msg, TN(1), TN(2) - TN(1)));
* * * * * * * * TN(1) = TN(2) + 2;
* * * * * * }
* * * * * * functionReturnValue = HTTPHeader + Constants.vbCrLf + Constants.vbCrLf + HTTPBody;
* * * * }
* * * * else {
* * * * * * functionReturnValue = ServerHttp;
* * * * }
* * * * * *
* * * * return functionReturnValue;
* * }
* *
* * private string BuildHttpCookies(ref tData[] CookieData)
* * {
* * * *
* * * * string CookieString = "";
* * * * short x = 0;
* * * *
* * * * if (Information.LBound(CookieData) != Information.UBound(CookieData)) {
* * * * * * for (x = Information.LBound(CookieData); x <= Information.UBound(CookieData); x++) {
* * * * * * * * CookieString = CookieString + CookieData(x).Key + "=" + CookieData(x).Value + "; ";
* * * * * * }
* * * * * * CookieString = VB.Left(CookieString, Strings.Len(CookieString) - 2);
* * * * }
* * * *
* * * * if (!string.IsNullOrEmpty(CookieString)) {
* * * * * * CookieString = "Cookie: " + CookieString + Constants.vbCrLf;
* * * * }
* * * *
* * * * * *
* * * * return CookieString;
* * }
* *
* * private void DecodeCookies()
* * {
* * * * // ERROR: Not supported in C#: OnErrorStatement
* * * * //UPGRADE_WARNING: Lower bound of array TN was changed from 1 to 0. Click for more: 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="0F1C9BE1-AF9D-476E-83B1-17D43BECFF20"'
* * * * int[] TN = new int[3];
* * * * string[] TempCookie = null;
* * * * short x = 0;
* * * * bool Ok2Add = false;
* * * * bool IsChanged = false;
* * * * short[] ChangedCookies = null;
* * * * short y = 0;
* * * *
* * * * TN(1) = 0;
* * * * y = 0;
* * * * // ERROR: Not supported in C#: ReDimStatement
* * * * while (true) {
* * * * * * TN(1) = Strings.InStr(TN(1) + 1, strINC, "Set-Cookie: ") + 12;
* * * * * * if (TN(1) == 12) break; // TODO: might not be correct. Was : Exit Do
* * * * * * TN(2) = Strings.InStr(TN(1), strINC, ";");
* * * * * * if (TN(2) == 0) break; // TODO: might not be correct. Was : Exit Do
* * * * * *
* * * * * * TempCookie = Strings.Split(Strings.Mid(strINC, TN(1), TN(2) - TN(1)), "=");
* * * * * * Ok2Add = true;
* * * * * * for (x = 0; x <= Information.UBound(Cookies); x++) {
* * * * * * * * if (Cookies(x).Key == TempCookie(0)) {
* * * * * * * * * * Ok2Add = false;
* * * * * * * * * * Cookies(x).Value = TempCookie(1);
* * * * * * * * * * IsChanged = true;
* * * * * * * * * * ChangedCookies(y) = x;
* * * * * * * * * * y = y + 1;
* * * * * * * * }
* * * * * * }
* * * * * * if (Ok2Add) {
* * * * * * * * if (!string.IsNullOrEmpty(Cookies(Information.UBound(Cookies)).Key)) {
* * * * * * * * * * Array.Resize(ref Cookies, Information.UBound(Cookies) + 2);
* * * * * * * * }
* * * * * * * * //UPGRADE_WARNING: Couldn't resolve default property of object Cookies(UBound()). Click for more: 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
* * * * * * * * Cookies(Information.UBound(Cookies)) = FormData(TempCookie(0), TempCookie(1));
* * * * * * * * IsChanged = true;
* * * * * * * * ChangedCookies(y) = Information.UBound(Cookies);
* * * * * * * * y = y + 1;
* * * * * * }
* * * * }
* * * * strKomplett = strINC;
* * * * strINC = "";
* * * * Winsock1.Close();
* * * * UBoundCookies = Information.UBound(Cookies);
* * * *
* * * * if (IsChanged) {
* * * * * * Array.Resize(ref ChangedCookies, y + 1);
* * * * * * if (CookieUpdate != null) {
* * * * * * * * CookieUpdate(this, new CookieUpdateEventArgs(ChangedCookies));
* * * * * * }
* * * * * *
* * * * }
* * }
* *
* * private void CurState_Change()
* * {
* * * * CurState.Refresh();
* * * * base.Refresh();
* * }
* *
* * public string iB(string strVariable, ref string str1, ref string str2, [System.Runtime.InteropServices.OptionalAttribute, System.Runtime.InteropServices.DefaultParameterValueAttribute(1)] ref // ERROR: Optional parameters aren't supported in C#
int lngBeginning)
* * {
* * * * // ERROR: Not supported in C#: OnErrorStatement
* * * * string iBetween = null;
* * * * int a = 0;
* * * * int b = 0;
* * * * int c = 0;
* * * *
* * * * b = Strings.InStr(lngBeginning, strVariable, str1);
* * * * c = Strings.InStr(b + Strings.Len(str1), strVariable, str2);
* * * *
* * * * if (b == System.DBNull.Value | c == System.DBNull.Value) {
* * * * * * iBetween = Constants.vbNullString;
* * * * * * return "";
* * * * }
* * * *
* * * * strVariable = Strings.Replace(strVariable, VB.Right(strVariable, Strings.Len(strVariable) - c + 1), Constants.vbNullString);
* * * *
* * * * strVariable = VB.Right(strVariable, Strings.Len(strVariable) - Strings.InStr(lngBeginning, strVariable, str1, CompareMethod.Text) - Strings.Len(str1) + 1);
* * * *
* * * * return strVariable;
* * }
* *
* * private void UserControl_Initialize()
* * {
* * * *
* * * * // ERROR: Not supported in C#: ReDimStatement
* * * *
* * * * DontParseHttp = false;
* * * * * *
* * * * StopIT = false;
* * }
* *
* * private void UserControl_Terminate()
* * {
* * * *
* * * * Winsock1.Close();
* * * * * *
* * * * WaitForWinSockClose();
* * }
* *
* * private void // ERROR: Handles clauses are not supported in C#
Winsock1_CloseEvent(System.Object eventSender, System.EventArgs eventArgs)
* * {
* * * *
* * * * DecodeCookies();
* * * * * *
* * * * Winsock1.Tag = "";
* * }
* *
* * private void // ERROR: Handles clauses are not supported in C#
Winsock1_ConnectEvent(System.Object eventSender, System.EventArgs eventArgs)
* * {
* * * *
* * * * * *
* * * * strINC = "";
* * }
* *
* * private void // ERROR: Handles clauses are not supported in C#
Winsock1_DataArrival(System.Object eventSender, AxMSWinsockLib.DMSWinsockControlEvents_DataArrivalEvent eventArgs)
* * {
* * * *
* * * * string strArrival = null;
* * * *
* * * * strArrival = "";
* * * * Winsock1.GetData(strArrival);
* * * * * *
* * * * strINC = strINC + strArrival;
* * }
* *
* * private void // ERROR: Handles clauses are not supported in C#
Winsock1_Error(System.Object eventSender, AxMSWinsockLib.DMSWinsockControlEvents_ErrorEvent eventArgs)
* * {
* * * *
* * * * * *
* * * * Winsock1.Close();
* * }
* *
* * private void // ERROR: Handles clauses are not supported in C#
Timer1_Tick(System.Object eventSender, System.EventArgs eventArgs)
* * {
* * * * // ERROR: Not supported in C#: OnErrorStatement
* * * * Timer1.Enabled = !DesignMode;
* * * * CurState.Text = (string)Winsock1.CtlState;
* * * * if (Winsock1.CtlState == 8 & string.IsNullOrEmpty(Winsock1.Tag)) {
* * * * * * Winsock1.Close();
* * * * * * Winsock1.Tag = "Closing";
* * * * * *
* * * * }
* * }
* *
* * private decimal Dez(ref string h)
* * {
* * * * decimal functionReturnValue = default(decimal);
* * * * // ERROR: Not supported in C#: OnErrorStatement
* * * * string Tmp = null;
* * * * short lo1 = 0;
* * * * short lo2 = 0;
* * * * int hi1 = 0;
* * * * int hi2 = 0;
* * * * const string Hx = "&H";
* * * * const int BigShift = 65536;
* * * * const short LilShift = 256;
* * * * const short Two = 2;
* * * *
* * * * Tmp = h;
* * * *
* * * * //In case "&H" is present
* * * * if (Strings.UCase(VB.Left(h, 2)) == "&H") {
* * * * * * Tmp = Strings.Mid(h, 3);
* * * * }
* * * *
* * * * //In case there are too few characters
* * * * Tmp = VB.Right("0000000" + Tmp, 8);
* * * *
* * * * //In case it wasn't a valid number
* * * * if (Information.IsNumeric(Hx + Tmp)) {
* * * * * * lo1 = (short)Hx + VB.Right(Tmp, Two);
* * * * * * hi1 = (int)Hx + Strings.Mid(Tmp, 5, Two);
* * * * * * lo2 = (short)Hx + Strings.Mid(Tmp, 3, Two);
* * * * * * hi2 = (int)Hx + VB.Left(Tmp, Two);
* * * * * * functionReturnValue = (decimal)hi2 * LilShift + lo2 * BigShift + (hi1 * LilShift) + lo1;
* * * * }
* * * * * *
* * * * return functionReturnValue;
* * }
* *
* * public string CookieKey_GET(ref short CIndex)
* * {
* * * *
* * * * * *
* * * * return Cookies(CIndex).Key;
* * }
* *
* * public string CookieValue_GET(ref short CIndex)
* * {
* * * *
* * * * * *
* * * * return Cookies(CIndex).Value;
* * }
* *
* * public void CookieKey_SET(ref short CIndex, ref string CookieKey)
* * {
* * * *
* * * * short[] ChangedCookies = new short[1];
* * * *
* * * * if (CIndex > Information.UBound(Cookies)) {
* * * * * * Array.Resize(ref Cookies, CIndex + 1);
* * * * * * UBoundCookies = Information.UBound(Cookies);
* * * * }
* * * *
* * * * Cookies(CIndex).Key = CookieKey;
* * * * ChangedCookies(0) = CIndex;
* * * * if (CookieUpdate != null) {
* * * * * * CookieUpdate(this, new CookieUpdateEventArgs(ChangedCookies));
* * * * * *
* * * * }
* * }
* *
* * public void CookieValue_SET(ref short CIndex, ref string CookieValue)
* * {
* * * *
* * * * short[] ChangedCookies = new short[1];
* * * *
* * * * if (CIndex > Information.UBound(Cookies)) {
* * * * * * Array.Resize(ref Cookies, CIndex + 1);
* * * * * * UBoundCookies = Information.UBound(Cookies);
* * * * }
* * * *
* * * * Cookies(CIndex).Value = CookieValue;
* * * * ChangedCookies(0) = CIndex;
* * * * if (CookieUpdate != null) {
* * * * * * CookieUpdate(this, new CookieUpdateEventArgs(ChangedCookies));
* * * * * *
* * * * }
* * }
* *
* * public void ClearCookies()
* * {
* * * *
* * * * short[] ChangedCookies = null;
* * * * short x = 0;
* * * * short y = 0;
* * * *
* * * * // ERROR: Not supported in C#: ReDimStatement
* * * *
* * * * y = 0;
* * * * for (x = Information.UBound(Cookies); x >= 0; x += -1) {
* * * * * * ChangedCookies(y) = (x * (-1)) - 1;
* * * * * * y = y + 1;
* * * * }
* * * *
* * * * // ERROR: Not supported in C#: ReDimStatement
* * * * UBoundCookies = Information.UBound(Cookies);
* * * * if (CookieUpdate != null) {
* * * * * * CookieUpdate(this, new CookieUpdateEventArgs(ChangedCookies));
* * * * * *
* * * * }
* * }
* *
* * public void RemoveCookie(ref short CIndex)
* * {
* * * *
* * * * short[] ChangedCookies = new short[1];
* * * * short x = 0;
* * * *
* * * * for (x = CIndex; x <= Information.UBound(Cookies) - 1; x++) {
* * * * * * Cookies(x).Key = Cookies(x + 1).Key;
* * * * * * Cookies(x).Value = Cookies(x + 1).Value;
* * * * }
* * * *
* * * * Array.Resize(ref Cookies, Information.UBound(Cookies));
* * * * UBoundCookies = Information.UBound(Cookies);
* * * * ChangedCookies(0) = (CIndex * (-1)) - 1;
* * * * if (CookieUpdate != null) {
* * * * * * CookieUpdate(this, new CookieUpdateEventArgs(ChangedCookies));
* * * * * *
* * * * }
* * }
* *
* * private void WaitForWinSockClose()
* * {
* * * *
* * * * System.DateTime waitUntilTime = default(System.DateTime);
* * * *
* * * * waitUntilTime = DateAdd(Microsoft.VisualBasic.DateInterval.Second, 7.0, Now);
* * * * //timeout is 7 seconds from now
* * * *
* * * * while (!(Winsock1.CtlState == 0)) {
* * * * * * SecondsToWait(0);
* * * * * * if (waitUntilTime < Now) {
* * * * * * * * Winsock1.Close();
* * * * * * * * //try again
* * * * * * * * WaitForWinSockClose();
* * * * * * }
* * * * * *
* * * * }
* * }
* *
* * private void WaitForWinSockConnect()
* * {
* * * *
* * * * System.DateTime waitUntilTime = default(System.DateTime);
* * * *
* * * * waitUntilTime = DateAdd(Microsoft.VisualBasic.DateInterval.Second, 7.0, Now);
* * * * //timeout is 7 seconds from now
* * * *
* * * * while (!(Winsock1.CtlState == 7 | StopIT)) {
* * * * * * SecondsToWait(0);
* * * * * * if (waitUntilTime < Now) {
* * * * * * * * Winsock1.Close();
* * * * * * * * WaitForWinSockClose();
* * * * * * * * Winsock1.Connect();
* * * * * * * * //try connecting again
* * * * * * * * WaitForWinSockConnect();
* * * * * * }
* * * * * *
* * * * }
* * }
}[/1][/1][/1][/3][/3]