bobthemac
bobthemac

Reputation: 1172

Add char array to LoadLibrary

I need to load a dll using a static library i know how to load the dll but I can't workout how to add my character array to load library. I have tried using a for loop but it wouldn't run inside the load library brackets. I can't use a string because it's against the specification I have been given.

int PlayARound(int &score, int &numAsked, char roundName[])
{
    HINSTANCE hinstLib;
    getQuesPnt ProcAdd;
    BOOL fFreeResult, fRunTimeLinkSuccess = FALSE;

    hinstLib = LoadLibrary();
}

I should say that this is homework so I am not looking for a complete solution just to be pointed in the right direction.

Upvotes: 1

Views: 566

Answers (1)

user1773602
user1773602

Reputation:

As it was discovered in comments all you need is cast your array to LPCTSTR

hinstLib = LoadLibrary((LPCTSTR)roundName);

However the proper way would have been to change the declaration

int PlayARound(int &score, int &numAsked, LPCTSTR roundName);

and then use TEXT macro to make your program unicode aware

PlayARound(score, numAsked, TEXT("demo.dll"));

Upvotes: 2

Related Questions