Cannot compile
Hi All,
I have downloaded the following code to get the machine name and PDC from
MSDN. Unfortunlately, the compilation is failed.
#include <activeds.h>
#include <stdio.h>
int main()
{
HRESULT hr;
hr = CoInitialize(NULL);
IADsWinNTSystemInfo *pNtSys;
hr = CoCreateInstance(CLSID_WinNTSystemInfo,
NULL,
CLSCTX_INPROC_SERVER,
IID_IADsWinNTSystemInfo,
(void**) &pNtSys);
BSTR bstr;
hr = pNtSys->get_UserName(&bstr);
if (SUCCEEDED(hr)) {
printf("User: %S\n", bstr);
SysFreeString(bstr);
}
hr = pNtSys->get_ComputerName(&bstr);
if (SUCCEEDED(hr)) {
printf("Computer: %S\n", bstr);
SysFreeString(bstr);
}
hr = pNtSys->get_DomainName(&bstr);
if (SUCCEEDED(hr)) {
printf("Domain: %S\n", bstr);
SysFreeString(bstr);
}
hr = pNtSys->get_PDC(&bstr);
if (SUCCEEDED(hr)) {
printf("PDC: %S\n", bstr);
SysFreeString(bstr);
}
if(pNtSys) {
pNtSys->Release();
}
CoUninitialize();
return 0;
}
The error message is :-
Linking...
adscode.obj : error LNK2019: unresolved external symbol
__imp__CoUninitialize@0 referenced in function _main
adscode.obj : error LNK2019: unresolved external symbol
__imp__SysFreeString@4 referenced in function _main
adscode.obj : error LNK2019: unresolved external symbol
__imp__CoCreateInstance@20 referenced in function _main
adscode.obj : error LNK2001: unresolved external symbol
_CLSID_WinNTSystemInfo
adscode.obj : error LNK2001: unresolved external symbol
_IID_IADsWinNTSystemInfo
adscode.obj : error LNK2019: unresolved external symbol
__imp__CoInitialize@4 referenced in function _main
D:\VCExpress\ads\Debug\ads.exe : fatal error LNK1120: 6 unresolved externals
Thanks