Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to call "StrCpyW" function from "shlwapi.dll"? in C++?

I use Code::Blocks as IDE.

And I should use "libshlwapi.a" library in order to use "StrCpyW" function.

But I want to use that function without the library.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

In order to achieve that, I should call "shlwapi.dll".

So, I write my codes like this:

void StrCpyW(PWSTR a_wcResultString, PCWSTR p_cwcSourceString)
{
    typedef PWSTR (*tdStrCpyW)(PWSTR, PCWSTR);

    HMODULE hmShlwapi;

    hmShlwapi = LoadLibraryW(L"shlwapi.dll");

    if(hmShlwapi)
    {
        tdStrCpyW fnStrCpyW = (tdStrCpyW)GetProcAddress(hmShlwapi, "StrCpyW");

        fnStrCpyW(a_wcResultString, p_cwcSourceString);
    }

    FreeLibrary(hmShlwapi);
}

So, what is wrong in my codes?

>Solution :

Just use wcscpy instead so you don’t have to load any libraries.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading