Click here to Skip to main content
15,912,578 members
Home / Discussions / C#
   

C#

 
Generalhelp me plz Pin
fekra16-Apr-05 4:03
fekra16-Apr-05 4:03 
GeneralRe: help me plz Pin
Colin Angus Mackay16-Apr-05 10:49
Colin Angus Mackay16-Apr-05 10:49 
Questioncenter text? Pin
Larsson16-Apr-05 3:33
Larsson16-Apr-05 3:33 
AnswerRe: center text? Pin
Heath Stewart16-Apr-05 10:00
protectorHeath Stewart16-Apr-05 10:00 
GeneralRe: center text? Pin
Larsson16-Apr-05 10:11
Larsson16-Apr-05 10:11 
GeneralRe: center text? Pin
Heath Stewart16-Apr-05 10:24
protectorHeath Stewart16-Apr-05 10:24 
GeneralCookies and winforms Pin
Anonymous16-Apr-05 2:52
Anonymous16-Apr-05 2:52 
GeneralRe: Cookies and winforms Pin
Heath Stewart16-Apr-05 9:35
protectorHeath Stewart16-Apr-05 9:35 
You can P/Invoke InternetGetCookie like in the following example:
using System;
using System.Runtime.InteropServices;
 
class CookieSample
{
  [DllImport("wininet.dll", CharSet=CharSet.Auto, SetLastError=true)]
  static extern bool InternetGetCookie(string lpszUrlName,
    string lpszCookieName, [Out] string lpszCookieData,
    out uint lpdwSize);
 
  const int ERROR_SUCCESS = 0;
  const int ERROR_INSUFFICIENT_BUFFER = 122;
  const int ERROR_NO_MORE_ITEMS = 259;
 
  static void Main(string[] args)
  {
    if (args.Length != 1)
    {
      Console.Error.WriteLine("Error: please specify a URL.");
      Environment.Exit(1);
    }
 
    try
    {
      string data = GetCookie(args[0]);
      if (data != null)
        Console.WriteLine("Cookie data: " + data);
    }
    catch (Exception ex)
    {
      Console.Error.WriteLine(ex.Message);
      Environment.Exit(1);
    }
  }
 

  static string GetCookie(string url)
  {
    int error;
    uint dwSize = 0;
 
    // First get the size of the buffer required.
    if (InternetGetCookie(url, null, null, out dwSize))
    {
      error = Marshal.GetLastWin32Error();
      if (error == ERROR_SUCCESS)
      {
        string data = new string('\0', (int)dwSize);
        if (InternetGetCookie(url, null, data, out dwSize))
        {
          return data;
        }
      }
    }
 
    error = Marshal.GetLastWin32Error();
    if (error == ERROR_NO_MORE_ITEMS)
    {
      Console.Error.WriteLine("Error: no cookie for URL or parents.");
      return null;
    }
 
    // If we got this far something bad happened.
    throw new Exception("Error: unexpected failure.");
  }
}


This posting is provided "AS IS" with no warranties, and confers no rights.

Software Design Engineer
Developer Division Customer Product-lifecycle Experience
Microsoft

[My Articles] [My Blog]
GeneralRe: Cookies and winforms Pin
Anonymous16-Apr-05 23:55
Anonymous16-Apr-05 23:55 
GeneralRe: Cookies and winforms Pin
Heath Stewart17-Apr-05 16:21
protectorHeath Stewart17-Apr-05 16:21 
Generaltext color Pin
Larsson16-Apr-05 2:04
Larsson16-Apr-05 2:04 
GeneralRe: text color Pin
Heath Stewart16-Apr-05 9:09
protectorHeath Stewart16-Apr-05 9:09 
GeneralRe: text color Pin
Larsson16-Apr-05 10:12
Larsson16-Apr-05 10:12 
GeneralRe: text color Pin
Heath Stewart16-Apr-05 10:23
protectorHeath Stewart16-Apr-05 10:23 
QuestionSDL.Net on WinForm possible? Pin
RATC16-Apr-05 1:56
RATC16-Apr-05 1:56 
AnswerRe: SDL.Net on WinForm possible? Pin
Heath Stewart16-Apr-05 8:37
protectorHeath Stewart16-Apr-05 8:37 
GeneralRe: SDL.Net on WinForm possible? Pin
RATC16-Apr-05 10:01
RATC16-Apr-05 10:01 
GeneralRe: SDL.Net on WinForm possible? Pin
Heath Stewart16-Apr-05 10:38
protectorHeath Stewart16-Apr-05 10:38 
GeneralRe: SDL.Net on WinForm possible? Pin
RATC16-Apr-05 10:53
RATC16-Apr-05 10:53 
GeneralRe: SDL.Net on WinForm possible? Pin
Heath Stewart16-Apr-05 11:12
protectorHeath Stewart16-Apr-05 11:12 
GeneralRe: SDL.Net on WinForm possible? Pin
RATC16-Apr-05 11:16
RATC16-Apr-05 11:16 
GeneralEncryption/decryption problem Pin
Kordzik16-Apr-05 0:38
Kordzik16-Apr-05 0:38 
Questionanyone help with this ??? Pin
Imran Adam16-Apr-05 0:33
Imran Adam16-Apr-05 0:33 
AnswerRe: anyone help with this ??? Pin
DavidNohejl16-Apr-05 1:13
DavidNohejl16-Apr-05 1:13 
AnswerRe: anyone help with this ??? Pin
Heath Stewart16-Apr-05 8:30
protectorHeath Stewart16-Apr-05 8:30 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.