This is my code. It runs but not thing happen

#include <windows.h>
#include <iostream>
#include <string>
using namespace std;

void CreateFolder(const LPCWSTR path)
{   
    if(!CreateDirectory(path ,NULL))
    {
        return;
    }
}

void main()
{
    LPCWSTR x;
    string s = "E:\\data\\";
    x = (LPCWSTR)s.c_str();
    CreateFolder(x);

}

If you put debug output on line 10, does it print it out?

LPCWSTR is a ponter to a wchar_t* string. typecasting like you do on line 18 doesn't work. You have two choices: (1) turn off UNICODE strings and use just standard ascii strings or (2)
CreateFolder(L"E:\\DATA");

Note that the L in front of the string literal makes it a wchar_t* instead of char*

There are other choices and conversion functions, but you need to study about UNICODE strings.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.