博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Shlwapi.h头文件的使用
阅读量:7009 次
发布时间:2019-06-28

本文共 1510 字,大约阅读时间需要 5 分钟。

// TestShlwAPI.cpp : 定义控制台应用程序的入口点。

//
#include "stdafx.h"
#include <Shlwapi.h>
#pragma comment(lib,"shlwapi.lib")
#include <iostream>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
    // Valid file path name (file is there).
    char buffer_1[] = "C:\\Install.log";
    char *lpStr1;
    lpStr1 = buffer_1;
     WCHAR wsz1[64];
     swprintf(wsz1, L"%S", lpStr1);    
    // Invalid file path name (file is not there).
    char buffer_2[] = "C:\\TEST\\file.doc";
    char *lpStr2;
    lpStr2 = buffer_2;
    WCHAR wsz2[64];
    swprintf(wsz1, L"%S", lpStr1);   
    // Search for the presence of a file with a true result.
    //int retval = PathFileExists(lpStr1);
    int retval = PathFileExists(wsz1);
    if(retval == 1)
    {
        cout << "Search for the file path of : " << lpStr1 << endl;
        cout << "The file requested \"" << lpStr1 << "\" is a valid file" << endl;
        cout << "The return from function is: " << retval << endl;
    }
    else
    {
        cout << "The file requested " << lpStr1 << " is not a valid file" << endl;
        cout << "The return from function is: " << retval << endl;
    }
    // Search for the presence of a file with a false result.
    //retval = PathFileExists(lpStr2);
    retval = PathFileExists(wsz2);
    if(retval == 1)
    {
        cout << "\nThe file requested " << lpStr2 << " is a valid file" << endl;
        cout << "Search for the file path of: " << lpStr2 << endl;
        cout << "The return from function is: " << retval << endl;
    }
    else
    {
        cout << "\nThe file requested \"" << lpStr2 << "\" is not a valid file" << endl;
        cout << "The return from function is: " << retval << endl;
    }
    system("pause");
}

转载地址:http://frvtl.baihongyu.com/

你可能感兴趣的文章
微软将在新版Edge浏览器中支持广告拦截器
查看>>
意大利电信开始在米兰部署1Gbps宽带
查看>>
网络钓鱼防不胜防:大型科技公司竟被骗逾1亿美元
查看>>
联合光伏拟撤诉 *ST海润将免交2亿港元违约金
查看>>
网络间谍活动月光迷宫已演变成Turla
查看>>
欧洲运营商展开5GTango项目 应对特定行业市场
查看>>
Windows 10创作者更新将改进蓝牙功能
查看>>
睿联嘉业边缘融合大屏幕多媒体会议系统方案
查看>>
凯立德货车专用导航 应“运”而生
查看>>
光伏组件市场价格战下谁获益?
查看>>
价格血拼战频频上演 光伏业陷入集体焦虑
查看>>
聊天机器人真正的潜力,潜藏在个人金融领域
查看>>
英特尔或推可超频Kaby Lake酷睿i3处理器: 重拾赛扬300A荣光?
查看>>
要想在未来立足 微软等软件公司就必须折本研发硬件
查看>>
个人常用网址集合
查看>>
吉林省将建东北林业大数据中心
查看>>
从互联网到物联网:下一个创新风口到来
查看>>
郭台铭:苹果亚马逊已提供资金 协助富士康收购东芝闪存
查看>>
美40家互联网巨头联合致信特朗普:今后你该这么做
查看>>
记一次磁盘性能测试
查看>>