| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 872 人关注过本帖
标题:自学API的遇到的问题
只看楼主 加入收藏
JackyZhang
Rank: 2
等 级:论坛游民
帖 子:82
专家分:29
注 册:2010-7-12
结帖率:60%
收藏
已结贴  问题点数:20 回复次数:2 
自学API的遇到的问题
下面是书上的代码,为什么用vs2010编译通不过?
#include<Windows.h>
#include<stdlib.h>
#include<stdio.h>
#define BUFSIZE 1024
BOOL GetDirverInfo(LPSTR szDrive);
void main(void)
{
    CHAR szLogicalDriveStrings[BUFSIZE];
    PCHAR szDrive;
    ZeroMemory(szLogicalDriveStrings,BUFSIZE);
    GetLogicalDriveStrings(BUFSIZE-1,szLogicalDriveStrings);
    szDrive=(PCHAR)szLogicalDriveStrings;
    do
    {
        if(!GetDirverInfo(szDrive))
        {
            printf("\nGet Volume Information Error:%d",GetLastError());

        }
        szDrive +=(lstrlen(szDrive)+1);
    }
    while(*szDrive!='\x00');
}




错误提示:

1>------ 已启动全部重新生成: 项目: getdriverstring, 配置: Debug Win32 ------
1>生成启动时间为 2011/3/27 21:54:39。
1>_PrepareForClean:
1>  正在删除文件“Debug\getdriverstring.lastbuildstate”。
1>InitializeBuildStatus:
1>  正在对“Debug\getdriverstring.unsuccessfulbuild”执行 Touch 任务。
1>ClCompile:
1>  main.cpp
1>main.obj : error LNK2019: 无法解析的外部符号 "int __cdecl GetDirverInfo(char *)" (?GetDirverInfo@@YAHPAD@Z),该符号在函数 _main 中被引用
1>E:\Visual Studio 2010\Projects\getdriverstring\Debug\getdriverstring.exe : fatal error LNK1120: 1 个无法解析的外部命令
1>
1>生成失败。
1>
1>已用时间 00:00:02.25
========== 全部重新生成: 成功 0 个,失败 1 个,跳过 0 个 ==========
搜索更多相关主题的帖子: 自学 include 
2011-03-27 22:03
yuccn
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:何方
等 级:版主
威 望:167
帖 子:6814
专家分:42393
注 册:2010-12-16
收藏
得分:10 
那个函数是自定义的。
网上找到一段代码,不知是否合适你
BOOL GetDirverInfo(LPSTR szDrive)
{
        UINT uDriveType;
        DWORD dwVolumeSerialNumber;
        DWORD dwMaximumComponentLength;
        DWORD dwFileSystemFlags;
        CHAR szFileSystemNameBuffer[BUFSIZE];
        CHAR szDirveName[MAX_PATH];
        printf("\n%s\n",szDrive);
        uDriveType = GetDriveType(szDrive);
        switch(uDriveType)
        {
        case DRIVE_UNKNOWN:
                printf("The drive type cannot be determined. ");
                break;
        case DRIVE_NO_ROOT_DIR:
                printf("The root path is invalid, for example, no volume is mounted at the path. ");
                break;
        case DRIVE_REMOVABLE:
                printf("The drive is a type that has removable media, for example, a floppy drive or removable hard disk. ");
                break;
        case DRIVE_FIXED:
                printf("The drive is a type that cannot be removed, for example, a fixed hard drive. ");
                break;
        case DRIVE_REMOTE:
                printf("The drive is a remote (network) drive. ");
                break;
        case DRIVE_CDROM:
                printf("The drive is a CD-ROM drive. ");
                break;
        case DRIVE_RAMDISK:
                printf("The drive is a RAM disk. ");
                break;
        default:
                break;
        }
        if (!GetVolumeInformation(
                szDrive,
                szDirveName,
                MAX_PATH,
                &dwVolumeSerialNumber,
                &dwMaximumComponentLength,
                &dwFileSystemFlags,
                szFileSystemNameBuffer,
                BUFSIZE
                ))
        {
                return FALSE;
        }
        if(0!=lstrlen(szDirveName))
        {
                printf ("\nDrive Name is %s\n",szDirveName);
        }

        printf ("\nVolume Serial Number is %u",dwVolumeSerialNumber);
        printf ("\nMaximum Component Length is %u",dwMaximumComponentLength);
        printf ("\nSystem Type is %s\n",szFileSystemNameBuffer);

        if(dwFileSystemFlags & FILE_SUPPORTS_REPARSE_POINTS)
        {
                printf ("The file system does not support volume mount points.\n");
        }
        if(dwFileSystemFlags & FILE_VOLUME_QUOTAS)
        {
                printf ("The file system supports disk quotas.\n");
        }
        if(dwFileSystemFlags & FILE_CASE_SENSITIVE_SEARCH)
        {
                printf ("The file system supports case-sensitive file names.\n");
        }



        printf("...\n");
        return TRUE;
}

我行我乐
公众号:逻辑客栈
我的博客:
https://blog.yuccn. net
2011-03-28 09:26
_Unsolved
Rank: 2
等 级:论坛游民
帖 子:6
专家分:45
注 册:2011-3-28
收藏
得分:10 
你这个是工程配置问题....检查一下工程设置里该包含的库包含了没有
2011-03-28 18:31
快速回复:自学API的遇到的问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.015074 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved