⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.cpp

📁 Samsung 241x Windows CE 6.0 BSP, include touch panel driver, display driver, OAL, EBOOT, Keypad driv
💻 CPP
字号:
//
// Copyright (c) Microsoft Corporation.  All rights reserved.
//
//
// Use of this sample source code is subject to the terms of the Microsoft
// license agreement under which you licensed this sample source code. If
// you did not accept the terms of the license agreement, you are not
// authorized to use this sample source code. For the terms of the license,
// please see the license agreement between you and Microsoft or, if applicable,
// see the LICENSE.RTF on your install media or the root of your tools installation.
// THE SAMPLE SOURCE CODE IS PROVIDED "AS IS", WITH NO WARRANTIES.
//
#include <windows.h>
#include <ras.h>
#include "CreateRASBookActiveSync.h"


VOID DeleteLink(HINSTANCE hinst)
{
    TCHAR szRASBookLnk[256];
    LoadString(hinst, IDS_CREATERASBOOKACTIVESYNC_LINK, szRASBookLnk, 256);
    BOOL fDeleted = DeleteFile(szRASBookLnk);
    if (!fDeleted)
    {
        DWORD dwDeletedError = GetLastError();
        DEBUGMSG(1, (TEXT("CreateRASBookActiveSync.lnk not deleted.  Error %i\r\n"), (UINT) dwDeletedError));
    }
}

VOID CreateRASEntry(HINSTANCE hinst) 
{
    DWORD           cb;
    RASENTRY        RasEntry;
    RASENTRYNAME    RasEntryName;
    DWORD           cbRasEntryName;
    DWORD           cRasEntries;
    TCHAR           name[256];
 
    //
    // First create the default entry (usually "Desktop@19200")
    // if the RAS Phonebook has not been created yet. That is, the
    // first time RasEnumEntries is called after booting RAS will
    // create the default entry, setting it to use the first "direct"
    // device available such as "Serial Cable on COM1:".
    //
    cbRasEntryName = sizeof(RasEntryName);
    RasEntryName.dwSize = sizeof(RASENTRYNAME);
    cRasEntries = 0;
    RasEnumEntries(NULL, NULL, &RasEntryName, &cbRasEntryName, &cRasEntries);

    //
    // Now we create a new entry for the USB connection to the desktop.
    // First, retrieve settings for the default entry to initialize most
    // of the settings we will use for the USB connection.
    //
    RasEntry.dwSize = sizeof(RASENTRY);
    cb = sizeof(RASENTRY);
    RasGetEntryProperties (NULL, TEXT(""), &RasEntry, &cb, NULL, NULL);

    // Second, change the device name to "Serial on USB"
    LoadString(hinst, SOCKET_FRIENDLY_NAME, RasEntry.szDeviceName, RAS_MaxDeviceName + 1);

    // Third, set the name of the new entry to "`USB"
    LoadString(hinst, IDS_DEFAULT_NAME, name, _countof(name));

    // Finally, write the new entry out
    if (RasSetEntryProperties (NULL, name, &RasEntry, sizeof(RasEntry), NULL, 0)) 
    {
        DEBUGMSG (1, (TEXT("Error %d from RasSetEntryProperties\r\n"), GetLastError()));
    } 
    else 
    {
        HKEY hKey;
        DWORD dwDisp;
        DEBUGMSG (1, (TEXT("RasEntry '%s' Created\r\n"), name));
        if (ERROR_SUCCESS==RegCreateKeyEx(HKEY_CURRENT_USER, RK_CONTROLPANEL_COMM, 0, NULL, REG_OPTION_NON_VOLATILE,
                KEY_ALL_ACCESS, NULL, &hKey, &dwDisp))
        {
            RegSetValueEx(hKey, RV_CNCT, 0, REG_SZ, (LPBYTE)name, sizeof(TCHAR)*(1+lstrlen(name)));
            RegCloseKey(hKey);
        }
    }
 
    // Now, delete the link file.
    DeleteLink(hinst);
}

int WINAPI WinMain(
    HINSTANCE hinst,
    HINSTANCE hinstPrev,
    LPWSTR szCmdLine,
    int iCmdShow
)
{
    CreateRASEntry(hinst);
    return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -