Getting Error Message

I keep getting this error message

argument of type "const char*" is incompatible with parameter of type "LPCWSTR"

I want to create a directory if it doesnt already exist.
I found this example code, but I'm getting that error.

1
2
3
4
5
6
7
8
9
10
11
void findLists () {
	 if (CreateDirectory ("foo", NULL)) {
		 // Directory created
	 }
	 else if (ERROR_ALREADY_EXISTS == GetLastError ()) {
		 // Directory already exists
	 }
	 else {
		 // Failed for some other reason
	 }
}


Output Window
1>Source.obj : error LNK2019: unresolved external symbol "void __cdecl findLists(void)" (?findLists@@YAXXZ) referenced in function _main
1>MSVCRTD.lib(exe_winmain.obj) : error LNK2019: unresolved external symbol _WinMain@16 referenced in function "int __cdecl invoke_main(void)" (?invoke_main@@YAHXZ)
Last edited on
I think you are using a UNICODE build in your project. "foo" is a const char *, but Create Directory expects a LPCWSTR which is const wchar_t*.
The fix this call CreateDirectoryA ("foo", NULL)

The other about missing _WinMain@16 is that you have created a Windows application but probably use a normal main function.

To fix this set SubSystem to Console under Properties->Linker->System
Topic archived. No new replies allowed.