与托管对象交互操作.doc

与托管对象交互操作.doc

与托管对象交互操作 课堂练习:调用Win32 API 解决Win32PlaySound_Error类的PlaySound_DllImport 函数中的错误。 打开Win32PlaySound_ErrorClass 文件,查看PlaySound_DllImport 函数。在函数中有一个错误。你可以试着测试它以确认该错误。该错误是什么呢? 答:函数将ExactSpelling 显示设置为True;然而,EntryPoint被设置为PlaySound。但是,在Winmm.dll中,函数PlaySound并不存在;只有 PlaySoundA (Ansi) 和PlaySoundW (Unicode)存在。要纠正这个错误,将 ExactSpelling设置为False。另一个纠正此错误的方法是将EntryPoint显示设置为PlaySoundW。 习题 运行库为每个COM对象创建几个RCW a) 2 b) 1 c) 0 d) COM对象上的引用数目 答:B 在C#中,如果要使用API MessageBox,可以用: a) [DllImport(user32.dll)] public extern int MessageBox(int hWnd, String text, String caption, uint type); b) [DllImport(user32

文档评论(0)

1亿VIP精品文档

相关文档