Tech Off Thread

2 posts

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

C#: Set Offline mode in IE Web Component.

Back to Forum: Tech Off
  • User profile image
    D0X

    Hi to all!

    I have a question about wininet.dll lib for setting offline mode in IE.
    .NET framework 2.0 have new property for web component: isOffline return true if Offline mode is enabled, false otherwise...but this property is read-only.
    So, I must change this property when my application start (I have a web browser component...).
    I use wininet.dll lib through InteropServices and I have writed this code:

    this is my struct:

    public struct Struct_OFFLINE_MODE
        {
            public int dwConnectedState;
        }


    this is external method definition:

     [DllImport("wininet.dll", SetLastError = true)]
            private static extern bool InternetSetOption(IntPtr hInternet, int dwOption, IntPtr lpBuffer, int lpdwBufferLength);


    this is the method:

    private bool SetNoOfflineMode()
            {
                const int INTERNET_OPTION_CONNECTED_STATE = 64;
                const int INTERNET_STATE_CONNECTED = 1;

                Struct_OFFLINE_MODE no_off_mode;
                no_off_mode.dwConnectedState = INTERNET_STATE_CONNECTED;

                IntPtr intptrStruct = Marshal.AllocCoTaskMem(Marshal.SizeOf(no_off_mode));

                bool iReturn = InternetSetOption(IntPtr.Zero, INTERNET_OPTION_CONNECTED_STATE, intptrStruct, Marshal.SizeOf(no_off_mode));
                return iReturn;

    this method return true but property isn't set correctly...don't work... [6]

    I think have problems about "magic numbers" of const....

    You have any idea?

    TNX!

    D0X

  • User profile image
    D0X

    Really any person have setted this property? I am continuing to try but also nothing…nevertheless the solution would not have to be distant… [6]

Conversation locked

This conversation has been locked by the site admins. No new comments can be made.