Wednesday, 15 April 2015

Geting the file size of a system application on windows in C++ -



Geting the file size of a system application on windows in C++ -

i trying file size of scheme application on windows. test have created test application tries file size of smss.exe in c:\windows\system32\smss.exe fails error: error_file_not_found. file exist (i have checked). i've tried different methods getting file size, with: findfirstfile, createfile , getfilesizeex. homecoming same error. read file contents.

what doing wrong?

the code:

// test.cpp : defines entry point console application. // #include "stdafx.h" #include <windows.h> #include <stdio.h> #include <tchar.h> #include <iostream> __int64 getfilesize(lpwstr filepath) { win32_file_attribute_data fad; if (!getfileattributesex(filepath, getfileexinfostandard, &fad)) { _tprintf(text("\n cant file size file %s error %d"), filepath, getlasterror()); homecoming 0; } large_integer size; size.highpart = fad.nfilesizehigh; size.lowpart = fad.nfilesizelow; homecoming size.quadpart; } int _tmain(int argc, _tchar* argv[]) { _tprintf(text("file size %d "), getfilesize(l"c:\\windows\\system32\\smss.exe")); }

as application 32-bit, scheme redirects path go syswow64 instead, there no smss.exe. while have discovered wow64disablewow64fsredirection disables redirection, consider having 64-bit programme trick.

c++ windows

No comments:

Post a Comment