Jump to content
  • Advertisement

NecoSpes

Member
  • Content count

    46
  • Joined

  • Last visited

Everything posted by NecoSpes

  1. Ok, I use this function for my Parent window: public void Pause(int milliseconds) { DateTime timer1 = DateTime.Now; DateTime timer2 = DateTime.Now; TimeSpan diff = timer2 - timer1; while (diff.TotalMilliseconds < milliseconds) { timer2 = DateTime.Now; diff = timer2 - timer1; Application.DoEvents(); } } And it works just fine. But when I use this function in a dialog, the dialog freezes until the pause is over. How do I fix this?
  2. I need a collection data type that will handle something like a table. Like this: Item Name, Price, ID, Model# Laptop1, 999, 1, X32 Laptop2, 999, 2, X33 I was thinking of a list of lists, but is there a better data type for this? It's be nice to sort by a specific category too. Thanks.
  3. I want to make a program that will add to a database via a website, but I want that website to only allow my program to add to the database. Can I do this using C# and PHP?
  4. Right now I'm calling Application.Exit() in a child dialog, but when the child dialog exits, the parent form still runs for a little bit, which is not good. How do I make sure it exits faster? Edit: Well I solved the problem seconds after posting this, I'm still curious about ways to do it though. Edit Again: I thought I solved it, but I did not. :(
  5. NecoSpes

    Exitting an Application

    Yes, I've already done that, and it does enter the if statement. There's quite a bit of code, but here is some more: public bool Login() { if (LgnDlg.ShowDialog() == DialogResult.Cancel) { return false; } return true; } That's the Login() function. LgnDlg is a form that has an button that returns DialogResult.Cancel, and is supposed to trigger the Application.Exit(). Before, I had the button in LgnDlg directly call Application.Exit(), but that didn't work. =/
  6. NecoSpes

    Exitting an Application

    I've just now realized that the program is not exiting at all. =/ if (Login() == false) { Hide(); Application.Exit(); return; } In fact, it's not calling Hide() either. It's like it's skipping to the return.
  7. How would you hide code from things like OllyDebug or something?
  8. NecoSpes

    Hiding Code

    Well, in my program I might put cheats in there, but I don't really want it to be easy to find by opening up the program in OllyDbg.
  9. I downloaded an image from a link ending like this: ?image=faf4d35f19152b4248d8886aa223431b But now I want to convert it into a Bitmap in C#. How would I go about doing this?
  10. Is there a way I can do "[^(WORD)]+" ? So that, it will match to every character in this sequence until "word": "abcaksjnfakcikjWORDkjancjkl". I want to parse certain words out of a very long pattern, and it would be a lot easier if I could do something like what I said above.
  11. NecoSpes

    Regular Expressions Help

    Something like this: "Item: Laptop <awiefawljaslkjfwijalkfja>\<\a\>\<br\>20 in Stock <fasdfasdsakjflkasdflsajdflkasfl;ask> Price: 1,000" I want to get the Laptop, 20, and 1,000 out. And to clarify, ".*WORD" will match "abcaksjnfakcikjWORD" ? The .* is like a wild card?
  12. I'm pretty sure I know what a StackOverflowException is, I've seen it happen when I put big numbers in a recursive program, but I don't see how it's happening here. It occurs when I call the method Request, around where the comment indicates. using System; using System.Collections.Generic; using System.Text; using System.Net; using System.IO; public class Interweb { public CookieCollection Cookies { get { return Cookies; } set { Cookies = value; } } public Interweb() { } public String Request(String Method, String URL, String Post, String Referer) { HttpWebRequest http = (HttpWebRequest)WebRequest.Create(URL); http.Timeout = 10000; http.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.1) Gecko/2008070208 Firefox/3.0.1"; http.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"; http.Referer = Referer; http.CookieContainer = new CookieContainer(); Console.WriteLine("Check"); if (Cookies != null && Cookies.Count > 0) //StackOverflowException happens hereish { http.CookieContainer.Add(Cookies); } Console.WriteLine("Check"); if (Method == "POST") { http.Method = "POST"; byte[] postBuffer = Encoding.GetEncoding(1252).GetBytes(Post); http.ContentLength = postBuffer.Length; Stream sendPost = http.GetRequestStream(); sendPost.Write(postBuffer, 0, postBuffer.Length); sendPost.Close(); } HttpWebResponse response = (HttpWebResponse)http.GetResponse(); if (response.Cookies.Count > 0) { if (Cookies == null) { Cookies = response.Cookies; } else { foreach (Cookie respCookies in response.Cookies) { bool match = false; foreach (Cookie currentCookies in Cookies) { if (respCookies.Name == currentCookies.Name) { currentCookies.Value = respCookies.Value; match = true; break; } } if (!match) { Cookies.Add(respCookies); } } } } Encoding enc = Encoding.GetEncoding(1252); StreamReader respStream = new StreamReader(response.GetResponseStream(), enc); String html = respStream.ReadToEnd(); return html; } }
  13. NecoSpes

    StackOverflowException help

    Yup that was it, thanks.
  14. NecoSpes

    StackOverflowException help

    Well, I tried the debugger, and it said the exception happened here: get { return Cookies; //here } I'm coming to C# from C++/Java, so I'm not very familiar with properties. Edit- It looks like this line causes the exception because it calls Interweb.Cookies.get() like a billion times. How do I fix this? [Edited by - NecoSpes on August 24, 2008 4:35:25 AM]
  15. NecoSpes

    StackOverflowException help

    Nothing shows up. I think that it happens at this line: http.CookieContainer.Add(Cookies);
  16. NecoSpes

    StackOverflowException help

    It just says System.Net.CookieContainer when I do Console.WriteLine(http.CookieContainer = new CookieContainer());
  17. I get this error: error CS0234: The type or namespace name 'Net' does not exist in the namespace 'System' (are you missing an assembly reference?) From this line: using System.Net; How do I fix this?
  18. NecoSpes

    Net not found in System Namespace

    Here it is: <?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <ProductVersion>9.0.21022</ProductVersion> <SchemaVersion>2.0</SchemaVersion> <ProjectGuid>{017A53B5-8AB9-4C91-922D-60619739FCC0}</ProjectGuid> <OutputType>Exe</OutputType> <AppDesignerFolder>Properties</AppDesignerFolder> <RootNamespace>Interweb</RootNamespace> <AssemblyName>Interweb</AssemblyName> <TargetFrameworkVersion>v3.5</TargetFrameworkVersion> <FileAlignment>512</FileAlignment> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <DebugSymbols>true</DebugSymbols> <DebugType>full</DebugType> <Optimize>false</Optimize> <OutputPath>bin\Debug\</OutputPath> <DefineConstants>DEBUG;TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <DebugType>pdbonly</DebugType> <Optimize>true</Optimize> <OutputPath>bin\Release\</OutputPath> <DefineConstants>TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> </PropertyGroup> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <!-- To modify your build process, add your task inside one of the targets below and uncomment it. Other similar extension points exist, see Microsoft.Common.targets. <Target Name="BeforeBuild"> </Target> <Target Name="AfterBuild"> </Target> --> <ItemGroup> <Compile Include="Internet.cs" /> </ItemGroup> <ItemGroup> <Reference Include="System.Net"> <RequiredTargetFramework>3.5</RequiredTargetFramework> </Reference> </ItemGroup> </Project>
  19. NecoSpes

    Net not found in System Namespace

    Quote:Original post by mutex Can you post the contents of your .csproj file? What does this mean? I thought that was the project file, so when I open it up I see the source I posted before. And I'm using VS 2008, but I did try what gan said, and it worked! However, I'd like to find a way for it to work in VS. Any ideas?
  20. NecoSpes

    Net not found in System Namespace

    Yes, I do have that line in my code. The whole code: using System; using System.IO; using System.Net; using System.Text; class Internet { static void Main(string[] args) { StringBuilder sb = new StringBuilder(); byte[] buf = new byte[8192]; System.Net.HttpWebRequest request = (System.Net.HttpWebRequest)System.Net.WebRequest.Create("http://www.espn.com"); System.Net.HttpWebResponse response = (System.Net.HttpWebResponse)request.GetResponse(); Stream refStream = response.GetResponseStream(); string tempString = null; int count = 0; do { count = refStream.Read(buf, 0, buf.Length); if (count != 0) { tempString = Encoding.ASCII.GetString(buf, 0, count); sb.Append(tempString); } } while (count > 0); Console.WriteLine(sb.ToString()); } } And the error: Internet.cs(12,20): error CS0234: The type or namespace name 'HttpWebRequest' does not exist in the namespace 'System.Net' (are you missing an assembly reference?) Internet.cs(12,57): error CS0234: The type or namespace name 'HttpWebRequest' does not exist in the namespace 'System.Net' (are you missing an assembly reference?) Internet.cs(12,83): error CS0234: The type or namespace name 'WebRequest' does not exist in the namespace 'System.Net' (are you missing an assembly reference?) Internet.cs(13,20): error CS0234: The type or namespace name 'HttpWebResponse' does not exist in the namespace 'System.Net' (are you missing an assembly reference?) Internet.cs(13,59): error CS0234: The type or namespace name 'HttpWebResponse' does not exist in the namespace 'System.Net' (are you missing an assembly reference?)
  21. NecoSpes

    Net not found in System Namespace

    Ok, I did that, but now I'm getting the same error except with HttpWebRequest, WebRequest, and HttpWebResponse. I get the error here: HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://www.espn.com"); HttpWebResponse response = (HttpWebResponse)request.GetResponse();
  22. I was looking at the System.Web classes and there's a lot of them. I'm not sure which one to use. Which one would I want to: 1. Log in a website(Like espn.com or a forum like this) 2. Search a site that has search box 3. Get info from a site 4. Get info from a java application that updates and stuff(like ESPN's live draft application) Bonus question: Do you know any good tutorials for it? Thanks a lot.
  23. NecoSpes

    Wininet Help

    Ok, I fixed it by changing INTERNET_FLAG_ASYNC to 0. Now my output comes out as "Bad Request" and says "Your browser made a request this server could not understand."
  24. Ok, so when I run this, nothing happens. It's supposed to get the contents of google.com. :( Some of it I copied from this tutorial. I don't exactly get how dwRead is used here. I tried to look up what a DWORD was, and I only sort of get it. :( #include <iostream> #include <string> #include <windows.h> #include <wininet.h> using namespace std; int main() { HINTERNET hInternet = InternetOpen("Microsoft Internet Explorer", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, INTERNET_FLAG_ASYNC); if(!hInternet) cout << "error" << endl; HINTERNET hSite = InternetConnect(hInternet, "http://www.google.com/", 80, " "," ", INTERNET_SERVICE_HTTP, 0, 0); if(!hSite) cout << "error" << endl; CHAR buffer[2048]; string contents; DWORD dwRead, dwFlags, dwStatus; HINTERNET hData = HttpOpenRequest( hSite, "GET", "", NULL, NULL, NULL, INTERNET_FLAG_KEEP_CONNECTION, 0 ); if(!hData) cout << "error" << endl; HttpSendRequest( hData, NULL, 0, NULL, 0); while( InternetReadFile( hData, buffer, 255, &dwRead ) ) { if ( dwRead == 0 ) return 0; buffer[dwRead] = 0; cout << buffer << endl; contents += buffer; } InternetCloseHandle(hData); InternetCloseHandle(hSite); InternetCloseHandle(hInternet); return 0; } Thanks :)
  25. NecoSpes

    Wininet Help

    Yeah, each of the "error"s used to be GetLastError(), but nothing showed up. I also put a GetLastError() after the while loop, and nothing showed up. Oh...I just put one after the HttpSendRequest. I got the error code 997, which is: Overlapped I/O operation is in progress. What does this mean?
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!