wcout 问题

arden1019 arden1019 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
#include <windows.h>
#include <tchar.h>
#include <iostream>
#include <winldap.h>
#include <iads.h>
#include <Adshlp.h>

int _tmain(int /* argc */, _TCHAR /* **argv */, _TCHAR /* **envp */)
{
IADs *pobjADs; // Pointer to object interface
BSTR bstrName; // String with object name
HRESULT hResult; // COM result code

// String to directory service
WCHAR *pstrADsPath =L"LDAP://ldap.itd.umich.edu/O=University of Michigan,C=us";
// Initalize COM
CoInitialize ( NULL );


// Get pointer to object's IADs interface
hResult = ADsGetObject( pstrADsPath, IID_IADs, (void**) &pobjADs);


// Check for success
if ( SUCCEEDED ( hResult ) )
{
// Get the Name property from the object
hResult = pobjADs->get_Name ( &bstrName );

// Check for success
if ( SUCCEEDED ( hResult ) )
{
// Display Name property
// (must use wide strings when working with COM)
wcout << L"The name of the object found is: "<< bstrName <<endl;
}
else
{
wcerr << L"Error occured while getting the object name: "
<< hResult << endl;
}
// When finished with the interface, call the
// Release method to free object
pobjADs->Release();
}
else
{
wcerr << L"Error occured while getting the object: "
<< hResult << endl;
}


// Unload COM
CoUninitialize ();


// Return the result of any failures
return hResult;
}

在vc6中调试结果如下:

eleting intermediate files and output files for project '2 - Win32 Debug'.
--------------------Configuration: 2 - Win32 Debug--------------------
Compiling...
2.cpp
d:\myprogram\2\2.cpp(35) : error C2065: 'wcout' : undeclared identifier
d:\myprogram\2\2.cpp(35) : error C2297: '<<' : illegal, right operand has type 'unsigned short [34]'
d:\myprogram\2\2.cpp(35) : error C2065: 'endl' : undeclared identifier
d:\myprogram\2\2.cpp(39) : error C2065: 'wcerr' : undeclared identifier
d:\myprogram\2\2.cpp(40) : error C2297: '<<' : illegal, right operand has type 'unsigned short [46]'
d:\myprogram\2\2.cpp(49) : error C2297: '<<' : illegal, right operand has type 'unsigned short [41]'
Error executing cl.exe.

2.exe - 6 error(s), 0 warning(s)

wout 不就在iostream中么?为什么说我未声明?
...全文
评论 3
收藏 已收藏
分享
返回顶部
arden1019
VC/MFC 16,551 成员 421,605 内容