求助,如何用C++判断调用者的文件大小

al525la 2014-11-26 03:21:58
C++编写DLL供几个C#程序调用,能不能在C++里判断调用者exe的文件大小。
如何实现?
求大神帮帮忙,谢谢了


...全文
266 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
al525la 2014-11-27
  • 打赏
  • 举报
回复
引用 5 楼 baijiaheizhiganmao 的回复:
读取文件会吗? 使用一个循环,从文件头读取到文件尾,统计读取的字节数. 思路就是这样
我那是固定的吧,可能视同的exe或dll调用我
忘世麒麟 2014-11-27
  • 打赏
  • 举报
回复
读取文件会吗? 使用一个循环,从文件头读取到文件尾,统计读取的字节数. 思路就是这样
al525la 2014-11-27
  • 打赏
  • 举报
回复
没有人知道了吗
赵4老师 2014-11-27
  • 打赏
  • 举报
回复
GetModuleFileNameEx The GetModuleFileNameEx function retrieves the fully qualified path for the specified module. DWORD GetModuleFileNameEx( HANDLE hProcess, // handle to the process HMODULE hModule, // handle to the module LPTSTR lpFilename, // buffer that receives the path DWORD nSize // size of the buffer ); Parameters hProcess Handle to the process that contains the module. hModule Handle to the module. lpFilename Pointer to the buffer that receives the fully qualified path to the module. nSize Specifies the size, in bytes, of the lpFilename buffer. Return Value If the function succeeds, the return value specifies the length of the string copied to the buffer. If the function fails, the return value is zero. To get extended error information, call GetLastError. See Also Process Status Helper Overview, PSAPI Functions, EnumProcesses, GetModuleBaseName
sniffer12345 2014-11-27
  • 打赏
  • 举报
回复
为什么会有这么蛋疼的需求? 不会是你们想通过调用文件的大小来判断不同的操作吧?
Marcelxx 2014-11-27
  • 打赏
  • 举报
回复
文件的尾指针减去头指针就等于文件的大小。
al525la 2014-11-26
  • 打赏
  • 举报
回复
引用 2 楼 jianwen0529 的回复:
取得exe路径 获取文件大小 自行搜索“C++ 获取程序路径”
这不是固定这个exe了吗,我想知道谁调用我的文件大小,可能是exe,可能是dll,不确定啊
幻夢之葉 2014-11-26
  • 打赏
  • 举报
回复
取得exe路径 获取文件大小 自行搜索“C++ 获取程序路径”
al525la 2014-11-26
  • 打赏
  • 举报
回复
着急啊,求大家帮帮忙

64,664

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

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