一个读版本信息的API函数的用法(我想好好久都是错的,急死人了,英语文档又看不懂)

redwood 2004-01-12 04:09:27
在vc控制台下编译:
#include<windows.h>
#include<iostream.h>
void main()
{
char lptstrFilename[MAX_PATH];
DWORD dwHandle;
char dwLen[MAX_PATH];
char *lpData ;
BOOL success;
cout<<"please cin filename"<<endl;
cin>>lptstrFilename;
success=GetFileVersionInfo(lptstrFilename,dwHandle,dwLen,&lpData);
if(success)
cout<<lpData<<endl;
希望各位大哥给改一下

}
...全文
76 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
honglunxu 2004-01-12
  • 打赏
  • 举报
回复
#include<windows.h>
#include<iostream.h>
void main()
{
char lptstrFilename[MAX_PATH];
DWORD dwHandle = 0;
DWORD dwLen = 0;
char *lpData = NULL;
BOOL success;
cout<<"please cin filename"<<endl;
cin>>lptstrFilename;
dwLen = GetFileVersionInfoSize(lptstrFilename,0);
lpData = new char[dwLen+1];
success=GetFileVersionInfo(lptstrFilename,0,dwLen,lpData);
if(success)
cout<<lpData<<endl;
delete []lpData;
}


在setting中把version.lib 加入input
zhangcrony 2004-01-12
  • 打赏
  • 举报
回复
#include<windows.h>
#include<iostream.h>
void main()
{
char lptstrFilename[MAX_PATH];
DWORD dwHandle;
char dwLen[MAX_PATH];
char *lpData ;
BOOL success;
cout<<"please cin filename"<<endl;
cin>>dwLen[MAX_PATH]>>lptstrFilename;
success=GetFileVersionInfo(lptstrFilename,dwHandle,dwLen,&lpData);
if(success)
cout<<lpData<<endl;

}
bluebohe 2004-01-12
  • 打赏
  • 举报
回复
#include "stdafx.h"
#include<windows.h>
#include<iostream.h>
void main()
{
char lptstrFilename[MAX_PATH]="E:\\NOTEPAD.EXE";
DWORD dwLen=0;
char *lpData=NULL ;
unsigned long iHandle;
BOOL success;
dwLen=GetFileVersionInfoSize(lptstrFilename,&iHandle);
lpData=new char[dwLen];
success=GetFileVersionInfo(lptstrFilename,iHandle,dwLen,lpData);
void *buf=NULL;
unsigned int len=0;
success=VerQueryValue(lpData,"\\",&buf,&len);
VS_FIXEDFILEINFO *pp=(VS_FIXEDFILEINFO*)buf;
delete []lpData;
}
redwood 2004-01-12
  • 打赏
  • 举报
回复
大哥些,直接把我的源代码改了吧。我真的看不懂英语啊!!!!谢谢
jennifergiant 2004-01-12
  • 打赏
  • 举报
回复
同意楼上的
char lpData[bufferSize];
GetFileVersionInfo(lptstrFilename,dwHandle,dwLen,&lpData);
windyloft 2004-01-12
  • 打赏
  • 举报
回复
lptstrFilename
Pointer to a null-terminated filename string that specifies the file of interest.
Windows 95 and Windows 98: The short path form of the specified file name must be less than 126 characters.

dwHandle
This parameter is ignored.
dwLen
Specifies the size, in bytes, of the buffer pointed to by the lpData member.
Call the GetFileVersionInfoSize function first to determine the size, in bytes, of a file's version information. The dwLen member should be equal to or greater than that value.

If the buffer pointed to by lpData is not large enough, the function truncates the file's version information to the size of the buffer.

lpData
Pointer to a buffer to receive file-version information.
You can use this value in a subsequent call to the VerQueryValue function to retrieve data from the buffer.

The file version information is always in Unicode format.

windyloft 2004-01-12
  • 打赏
  • 举报
回复
BOOL GetFileVersionInfo(
LPTSTR lptstrFilename, // pointer to filename string
DWORD dwHandle, // ignored
DWORD dwLen, // size of buffer
LPVOID lpData // pointer to buffer to receive
// file-version info.
);
曾经的猎狐 2004-01-12
  • 打赏
  • 举报
回复
char *lpData ;
GetFileVersionInfo(lptstrFilename,dwHandle,dwLen,lpData);


char lpData ;
GetFileVersionInfo(lptstrFilename,dwHandle,dwLen,&lpData);

16,551

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Creator Browser
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧