importing a dll

Hi. I'm new to c++, and am trying to convert the following vb code to c++:

dim testCOM
set testCOM = createobject("NewCOM.testClass")
msgbox testCOM.printNum(4)
msgbox testCOM.info()
set testCOM = nothing



I tried importing NewCom.lib into the project using Project >> Add Existing item

#include <iostream>
#include <windows.h>

extern "C" __declspec(dllimport)int info();

int main()
{
std::cout << info();
return 0;
}


The compiler returns the following error:
error LNK2019: unresolved external symbol __imp__info referenced in function _main

Any help would be appreciated!
You need to read COM before even trying this.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
int main()
{
    CoInitialize();
    <interface name here> * pTest;
    HRESULT hr = CoCreateInstance(CLSID_TestClass, NULL, CLSCTX_ALL, IID_<interface name here>, (void**)&pTest);
    if (FAILED(hr))
    {
        //2Do:  Handle error.
        return <some error code>;
    }
    cout << pTest->info();
    pTest->Release();
    CoUninitialize();
}


I won't even try to explain the above because you are at least one good book away from trying to understand this. If you can understand enough of C++, you could try reading about COM in MSDN library.
Topic archived. No new replies allowed.