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

📄 ptree.cpp

📁 SMART PHONE 2005中关于RAPI的源码
💻 CPP
字号:
//
// Copyright (c) Microsoft Corporation.  All rights reserved.
//
//
// Use of this source code is subject to the terms of the Microsoft end-user
// license agreement (EULA) under which you licensed this SOFTWARE PRODUCT.
// If you did not accept the terms of the EULA, you are not authorized to use
// this source code. For a copy of the EULA, please see the LICENSE.RTF on your
// install media.
//
//*******************************************************************************************
//
// Filename : ptree.c
//    
//
//*******************************************************************************************
#include <stdio.h>
#include <tchar.h>
#include <rapi.h>
#include <strsafe.h>

#define ARRAYSIZE(x) (sizeof(x)/sizeof(x[0]))

void PrintDirectory(LPWSTR Path, UINT Indent)
{
    DWORD          foundCount;
    LPCE_FIND_DATA findDataArray;
    HRESULT        hr;

    WCHAR searchPath[MAX_PATH];

    hr = StringCchCopyW(searchPath, ARRAYSIZE(searchPath), Path);
    if(FAILED(hr))
    {
        return;
    }
    hr = StringCchCatW(searchPath, ARRAYSIZE(searchPath), L"*");
    if(FAILED(hr))
    {
        return;
    }

    if(!CeFindAllFiles(searchPath,
                        FAF_ATTRIBUTES | FAF_NAME,
                        &foundCount,
                        &findDataArray))
    {
        _tprintf( TEXT("*** CeFindAllFiles failed. ***\n"));
        return;
    }

    if(!foundCount)
        return;

    for(UINT i = 0; i < foundCount; i++)
    {
        for(UINT indCount = 0; indCount < Indent; indCount++)
            _tprintf( TEXT("  "));

        if(findDataArray[i].dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
        {
            _tprintf( TEXT("[%s]\n"),findDataArray[i].cFileName);
            WCHAR newPath[MAX_PATH];
            hr = StringCchCopyW(newPath, ARRAYSIZE(newPath), Path);
            if(FAILED(hr))
            {
                return;            
            }
            hr = StringCchCatW(newPath, ARRAYSIZE(newPath), findDataArray[i].cFileName);
            if(FAILED(hr))
            {
                return;
            }            
            hr = StringCchCatW(newPath, ARRAYSIZE(newPath), L"\\");
            if(FAILED(hr))
            {
                return;
            }
            PrintDirectory(newPath, Indent + 1);
        }
        else
        {
            _tprintf( TEXT("%s\n"),findDataArray[i].cFileName);
        }
    }

    if (findDataArray)
    {
        RapiFreeBuffer(findDataArray);
    }
}

void main()
{
    HRESULT hRapiResult;

    _tprintf( TEXT("Connecting to Windows CE..."));
    
    hRapiResult = CeRapiInit();

    if (FAILED(hRapiResult))
    {
        _tprintf( TEXT("Failed\n"));
        return;
    }

    _tprintf( TEXT("Success\n"));

    PrintDirectory( L"\\", 0);

    CeRapiUninit();
}

⌨️ 快捷键说明

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