Board logo

標題: 安裝vLan 後開機變慢 [打印本頁]

作者: tc0312    時間: 2006-11-13 07:00     標題: 安裝vLan 後開機變慢

我是用ADSL 上網的。安裝vLan 後開機明顯變慢。查一查event viewer 後,發現這是因為IPvE adpater 在尋找DHCP server, 做成delay.
人手disable IPvE adpater後, 重新開機, 開機果然快了.
請問開發者可不可以在vLan 運作的時侯才enable IPvE adpater? 在結束vLan 時把IPvE adpater disable. 這樣就不會做成開機變慢了。
我現在寫了一個loader 來做以上的事。附上code 給大家參一參考。如開發者能夠把這項功能加到vLan 內就太好了。

以下是loader 的code.

#include "stdafx.h"
#include "vLanController.h"
#include <objbase.h>
#include <netcon.h>
#include <string.h>

HRESULT EnableVLanConnection(BOOL bEnable);

int APIENTRY _tWinMain(HINSTANCE hInstance,
                       HINSTANCE hPrevInstance,
                       LPTSTR    lpCmdLine,
                       int       nCmdShow)
{
    EnableVLanConnection(true);
    STARTUPINFO            si;
    PROCESS_INFORMATION pi;
    LPVOID                 lpMsgBuf = NULL;
    HHOOK                hKH = NULL;
    HANDLE              hKHDll = NULL;

    ZeroMemory(&si, sizeof(si));
    si.cb = sizeof(si);
    ZeroMemory(&pi, sizeof(pi));

    if(!CreateProcess(_T("C:\\Program Files\\vLan\\vLan.exe"), NULL, NULL, NULL, FALSE, 0, NULL, _T("C:\\Program Files\\vLan\\"), &si, &pi)) {
        
        MessageBox(0, _T("Failed to CreateProcess"), _T("Failed to CreateProcess"), 16);
        LocalFree(lpMsgBuf);
        return 0;
    }

    // Wait until child process exits.
    WaitForSingleObject(pi.hProcess, INFINITE);
    UnhookWindowsHookEx(hKH);
    // Close process and thread handles.

    CloseHandle(pi.hProcess);
    CloseHandle(pi.hThread);
    EnableVLanConnection(false);
    return 0;
}

HRESULT EnableVLanConnection(BOOL bEnable)
{
    HRESULT hr = E_FAIL;

    CoInitialize(NULL);

    INetConnectionManager *pNetConnectionManager = NULL;
    hr = CoCreateInstance(CLSID_ConnectionManager,
        NULL,
        CLSCTX_LOCAL_SERVER | CLSCTX_NO_CODE_DOWNLOAD,
        IID_INetConnectionManager,
        reinterpret_cast<LPVOID *>(&pNetConnectionManager)
        );
    if (SUCCEEDED(hr))
    {
        /*
        Get an enumurator for the set of connections on the system
        */
        IEnumNetConnection* pEnumNetConnection;
        pNetConnectionManager->EnumConnections(NCME_DEFAULT, &pEnumNetConnection);

        ULONG ulCount = 0;
        BOOL fFound = FALSE;

        hr = HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND);

        HRESULT hrT = S_OK;

        /*  
        Enumurate through the list of adapters on the system and look for the one we want
        NOTE: To include per-user RAS connections in the list, you need to set the COM
        Proxy Blanket on all the interfaces. This is not needed for All-user RAS
        connections or LAN connections.
        */
        do
        {
            NETCON_PROPERTIES* pProps = NULL;
            INetConnection *   pConn;

            /*
            Find the next (or first connection)
            */
            hrT = pEnumNetConnection->Next(1, &pConn, &ulCount);

            if (SUCCEEDED(hrT) && 1 == ulCount)
            {
                /*
                Get the connection properties
                */
                hrT = pConn->GetProperties(&pProps);

                if (S_OK == hrT)
                {
                    //printf("* %S\n", pProps->pszwName);

                    //MessageBox(0, pProps->pszwName, pProps->pszwName, 0);

                    if (!wcscmp(pProps->pszwName, _T("IPvE Adapter")))
                        if (bEnable)
                        {
                            //printf("      Enabling adapter: %S...\n",pProps->pszwName);
                            hr = pConn->Connect();
                        }
                        else
                        {
                            //printf("      Disabling adapter: %S...\n",pProps->pszwName);
                            hr = pConn->Disconnect();
                        }


                    CoTaskMemFree (pProps->pszwName);
                    CoTaskMemFree (pProps->pszwDeviceName);
                    CoTaskMemFree (pProps);
                }

                pConn->Release();
                pConn = NULL;
            }

        } while (SUCCEEDED(hrT) && 1 == ulCount && !fFound);

        if (FAILED(hrT))
        {
            hr = hrT;
        }

        pEnumNetConnection->Release();
    }

    if (FAILED(hr) && hr != HRESULT_FROM_WIN32(ERROR_RETRY))
    {
        //printf("Could not enable or disable connection (0x%08x)\r\n", hr);
    }

    pNetConnectionManager->Release();

    CoUninitialize();

    return hr;
}
作者: 龍之振雄    時間: 2006-11-13 09:27

非常感謝你如此細心提出建議, 並提供解決方法.
但是正常情況下, 在 vLan 未進入遊戲區前是不會進行任何實質運作的.
我懷疑是其他原因導致你所發現狀況.
作者: tc0312    時間: 2006-11-13 17:31

運作的是windows, 不是vlan.
因為ipve adapter 設定了用dhcp get IP, 在windows 開機時, windows 會嘗試為ipve adapter get IP. 但IPvE adapter 根本未連上網絡,一定找不到dhcp server, 這樣就要等timeout. 做成delay. 這其實就同使用adsl 上網的人自已assign static ip 給lan card 能加快開機速度的道理一樣。
作者: 龍之振雄    時間: 2006-11-14 19:50

引用:
原帖由 tc0312 於 2006-11-13 17:31 發表
運作的是windows, 不是vlan.
因為ipve adapter 設定了用dhcp get IP, 在windows 開機時, windows 會嘗試為ipve adapter get IP. 但IPvE adapter 根本未連上網絡,一定找不到dhcp server, 這樣就要等timeout. 做成delay ...
正常情況下,  IPvE Adapter 是不會自動運作, 其網線連線是斷開的.
你所遇到情況大概是有其他軟件使 IPvE Adapter 的網線連線接上了.




歡迎光臨 IPvE vLan 遊戲平台|網吧系統 (https://www.ipve.com/bbs/) Powered by Discuz! 6.0.0