Question: I want to develop a plugin system using LoadLibrary.   

My problem is: I want my function to take a `const char*` and `LoadLibrary` takes a `LPCTSTR`.   

I had the *bright* idea to do `(LPCSTR)path` which kept giving me a module not found error.   

Current code is below. If I uncomment the `widepath = L..` line it works fine. I've read solutions using MFC but I'd like to not use MFC.

Current code:

```
bool PluginLoader::Load(char *path)
{
    path = "Release\\ExamplePlugin.dll";
    LPCTSTR widepath = (LPCTSTR)path;
    //widepath = L"Release\\ExamplePlugin.dll";

    HMODULE handle = LoadLibrary(widepath);
    if (handle == 0)
    {
        printf("Path: %s\n",widepath );
        printf("Error code: %d\n", GetLastError());

        return false;
    }

    int (*load_callback)() = (int (*)()) GetProcAddress(handle, "_plugin_start@0");

    if (load_callback == 0)
    {
        return false;
    }

    return load_callback() == LOAD_SUCCESS;
}

```

Answer: 
Use LoadLibraryA(), it takes a const char\*.

Winapi functions that take strings exist in two versions, an A version that takes an Ansi string and a W version that takes a wide string. There's a macro for the function name, like LoadLibrary, that expands to either the A or the W flavor, depending if UNICODE is #defined. You are compiling your program with that #define in effect, so you get LoadLibraryW(). Simply cheat and use LoadLibraryA() explicitly.
If you continue to use a `char *` for the parameter, you'll run into cases where an unusual character is used in the filename and the LoadLibrary will fail. Change the function to use wchar\_t instead, and while you're at it make the parameter `const` since you're not modifying the string.

```
bool PluginLoader::Load(const wchar_t *path)

```

I think you'll find that LPCTSTR on 32-bit Windows is a macro that expands to `const wchar_t *` when the program options are set to Unicode.