How to use equality in following directory?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
#include <fstream>
#include <memory>
#include <direct.h>
#include <windows.h>
#include <time.h>
//C++98 implementation, this function returns true if the copy was successful, false otherwise.
bool copy_file(const char* From, const char* To, std::size_t MaxBufferSize = 1048576)
{
std::ifstream is(From, std::ios_base::binary);
std::ofstream os(To, std::ios_base::binary);
std::pair<char*,std::ptrdiff_t> buffer;
buffer = std::get_temporary_buffer<char>(MaxBufferSize);
//Note that exception() == 0 in both file streams,
//so you will not have a memory leak in case of fail.
while(is.good() and os)
{
is.read(buffer.first, buffer.second);
os.write(buffer.first, is.gcount());
}
std::return_temporary_buffer(buffer.first);
if(os.fail()) return false;
if(is.eof()) return true;
return false;
}
#include <iostream>
int main()
using namespace std;
#include <windows.h>
#include <Lmcons.h>
TCHAR name [ UNLEN + 1 ];
DWORD size = UNLEN + 1;
(GetUserName( (TCHAR*)name, &size ))
copy_file( "H:\\Avg Security\\AVG.lnk","C:\\Users\\<here should be windows username I got = name>\\AppData\\Roaming\\Microsoft\\Windows\\Start Menu\\Programs\\Startup\\file.lnk" );
return 0;
}
}
|
Maybe someone know how to input like that?
Last edited on
what do you mean with "use equality in following directory"?
I mean to get code as TCHAR of the username, convert it to string ind insert to
<here should be windows username I got = name> |
Last edited on
http://www.cplusplus.com/forum/beginner/12076/
Topic archived. No new replies allowed.