Error with parameter conversions

closed account (NUCkSL3A)
Hello, I am trying to make a program which tells the user its location, and puts its raw code into a text file at the root directory. The part that tells the user the location is fine, but the copy command isn't. Can anyone tell me what I'm doing wrong?

Error 1 error C2664: 'CopyFileW' : cannot convert parameter 2 from 'const char [15]' to 'LPCWSTR' c:\users\vlad\documents\visual studio 2008\projects\copy\copy\main.cpp

That's the error btw. Here's the code:

#include <iostream>
#include <windows.h>
#include <conio.h>

using namespace std;

int main()
{
wchar_t buffer[MAX_PATH];
GetModuleFileName( NULL, buffer, MAX_PATH );

cout <<"The location of this file is: \n "<<endl;
wcout <<buffer<<endl;
cout<<"\nPress any key to exit!"<<endl;

CopyFile( buffer, "C:\\rawcode.txt", 1);

_getch();

return 0;
}
any help will be great!

It seems you use unicode for your project, so you need to prefix your string literals with L
CopyFile( buffer, L"C:\\rawcode.txt", 1);
closed account (NUCkSL3A)
Ok. I will see if this will work. Thanks for the possible answer. Yep. This works! Thank you very much!
Last edited on
Topic archived. No new replies allowed.