Click here to Skip to main content
15,943,161 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Changing the location of a CFileDialog. Pin
Richard MacCutchan24-Oct-10 22:24
mveRichard MacCutchan24-Oct-10 22:24 
GeneralFound the problem Pin
rentzk25-Oct-10 7:38
rentzk25-Oct-10 7:38 
GeneralProject type for remote file access Pin
seifwen22-Oct-10 10:25
seifwen22-Oct-10 10:25 
GeneralRe: Project type for remote file access Pin
Moak22-Oct-10 10:37
Moak22-Oct-10 10:37 
GeneralRe: Project type for remote file access Pin
seifwen22-Oct-10 11:29
seifwen22-Oct-10 11:29 
GeneralRe: Project type for remote file access Pin
Moak23-Oct-10 2:06
Moak23-Oct-10 2:06 
GeneralRe: Project type for remote file access Pin
seifwen23-Oct-10 3:57
seifwen23-Oct-10 3:57 
QuestionEnable lan connection for win7 using INetConnection Pin
manojsaxena_mca22-Oct-10 2:31
manojsaxena_mca22-Oct-10 2:31 
I am enabling my LAN connection using the code:
try
{

    bool result = false;
    typedef void (__stdcall * LPNcFreeNetconProperties)(NETCON_PROPERTIES* pProps);
    HMODULE hmod = LoadLibrary(L"netshell.dll");

    if (!hmod)
        return false;

    LPNcFreeNetconProperties NcFreeNetconProperties =   (LPNcFreeNetconProperties)GetProcAddress(hmod, "NcFreeNetconProperties");

    if (!NcFreeNetconProperties )
        return false;


    INetConnectionManager * pMan = 0;
    HRESULT hres = CoCreateInstance(CLSID_ConnectionManager,
        0,
        CLSCTX_ALL,
        __uuidof(INetConnectionManager),
        (void**)&pMan);

    if (SUCCEEDED(hres))
    {

        IEnumNetConnection * pEnum = 0;
        hres = pMan->EnumConnections(NCME_DEFAULT, &pEnum);
        if (SUCCEEDED(hres))
        {

            INetConnection * pCon = 0;
            ULONG count;
            bool done = false;

            while (pEnum->Next(1, &pCon, &count) == S_OK && !done)
            {

                NETCON_PROPERTIES * pProps = 0;
                hres = pCon->GetProperties(&pProps);

                if (SUCCEEDED(hres))
                {

                    if (wcscmp(pProps->pszwName,wszName) == 0)
                    {
                        if (bEnable)
                            result = (pCon->Connect() == S_OK);
                        else
                            result = (pCon->Disconnect() == S_OK);

                        done = true;
                        result=true;
                    }

                    NcFreeNetconProperties(pProps);

                }

                pCon->Release();

            }

            pEnum->Release();

        }

        pMan->Release();

    }



    FreeLibrary(hmod);

    return result;
}


The code works fine for winXP but this is not having any effect when I run the same code in win7.

The function returns successfully but there is no effect on my LAN, it remains disabled.

I am not able to figure out where I am committing any mistake.



Thanks and regards,
Manoj
JokeRe: Enable lan connection for win7 using INetConnection Pin
josda100022-Oct-10 6:42
josda100022-Oct-10 6:42 
GeneralRe: Enable lan connection for win7 using INetConnection Pin
manojsaxena_mca24-Oct-10 21:29
manojsaxena_mca24-Oct-10 21:29 
AnswerRe: Enable lan connection for win7 using INetConnection Pin
krmed22-Oct-10 7:11
krmed22-Oct-10 7:11 
GeneralRe: Enable lan connection for win7 using INetConnection Pin
manojsaxena_mca24-Oct-10 21:02
manojsaxena_mca24-Oct-10 21:02 
GeneralRe: Enable lan connection for win7 using INetConnection Pin
krmed25-Oct-10 0:36
krmed25-Oct-10 0:36 
AnswerRe: Enable lan connection for win7 using INetConnection Pin
Richard MacCutchan22-Oct-10 23:01
mveRichard MacCutchan22-Oct-10 23:01 
GeneralRe: Enable lan connection for win7 using INetConnection Pin
manojsaxena_mca24-Oct-10 21:26
manojsaxena_mca24-Oct-10 21:26 
GeneralRe: Enable lan connection for win7 using INetConnection Pin
Richard MacCutchan24-Oct-10 22:33
mveRichard MacCutchan24-Oct-10 22:33 
GeneralRe: Enable lan connection for win7 using INetConnection Pin
manojsaxena_mca24-Oct-10 23:18
manojsaxena_mca24-Oct-10 23:18 
GeneralRe: Enable lan connection for win7 using INetConnection Pin
Richard MacCutchan25-Oct-10 0:26
mveRichard MacCutchan25-Oct-10 0:26 
GeneralRe: Enable lan connection for win7 using INetConnection Pin
manojsaxena_mca26-Oct-10 2:31
manojsaxena_mca26-Oct-10 2:31 
GeneralRe: Enable lan connection for win7 using INetConnection Pin
Richard MacCutchan26-Oct-10 3:35
mveRichard MacCutchan26-Oct-10 3:35 
GeneralRe: Enable lan connection for win7 using INetConnection Pin
manojsaxena_mca1-Nov-10 1:35
manojsaxena_mca1-Nov-10 1:35 
GeneralRe: Enable lan connection for win7 using INetConnection Pin
Richard MacCutchan2-Nov-10 9:30
mveRichard MacCutchan2-Nov-10 9:30 
GeneralRe: Enable lan connection for win7 using INetConnection Pin
manojsaxena_mca2-Nov-10 22:27
manojsaxena_mca2-Nov-10 22:27 
GeneralRe: Enable lan connection for win7 using INetConnection Pin
Richard MacCutchan3-Nov-10 4:37
mveRichard MacCutchan3-Nov-10 4:37 
QuestionShellExecute Pin
john563222-Oct-10 1:57
john563222-Oct-10 1:57 

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.