Newbie Question

Discussion in 'C++' started by Toli, Jun 23, 2003.

  1. Toli

    Toli Guest

    I have a simple question, im trying to access a dll called
    'runtest.dll', with a routine with the header:

    void RunTest(LPVOID lpData, int nDataLen, LPSTR szstrResult, int
    nMaxResLen)

    Currently my code, gives me an access violation writing with a memory
    address. The point of runtest.dll is to accept data from a file
    (lpData), and return (in szstrResult) a string created from the data
    (which is binary data). Sound simple enough? My code is below, any
    help is greatly appreciated. Thanks in advance.


    typedef VOID (*MYPROC)(LPVOID, int, LPSTR, int);
    void passFile(LPCSTR fileName)
    {
    HINSTANCE testLib;
    testLib = LoadLibrary("runtest.dll");
    if (testLib==0)
    {
    return;
    }
    MYPROC procTest;
    procTest = (MYPROC) GetProcAddress(testLib,"RunTest");

    HANDLE hFile;
    hFile = CreateFile(fileName, GENERIC_READ, FILE_SHARE_READ, NULL,
    OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
    CHAR buf[2048];
    DWORD dwNumRead=sizeof(buf);
    ReadFile(hFile, buf, sizeof(DWORD)*256,&dwNumRead,NULL);
    CHAR lpstrResult[256]
    (procTest) (buf,sizeof(buf),lpstrResult,sizeof(lpstrResult);
    FreeLibrary(testLib);
    }
    Toli, Jun 23, 2003
    #1
    1. Advertising

  2. Toli

    Dan Cernat Guest

    Hmm,


    LPVOID, LPSTR, HINSTANCE, DWORD ...

    try a Microsoft newsgroup.

    Dan
    Dan Cernat, Jun 24, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jerry C.
    Replies:
    8
    Views:
    201
    Uri Guttman
    Nov 23, 2003
  2. Kruno Saho
    Replies:
    0
    Views:
    121
    Kruno Saho
    Apr 7, 2013
  3. Dave Angel
    Replies:
    0
    Views:
    106
    Dave Angel
    Apr 7, 2013
  4. rusi
    Replies:
    0
    Views:
    98
  5. Miki Tebeka
    Replies:
    0
    Views:
    72
    Miki Tebeka
    Apr 7, 2013
Loading...

Share This Page