如何在 c++ 中使用 smo 库

发布于 2024-07-24 06:49:16 字数 108 浏览 5 评论 0原文

我试图在 vs2005 中使用 c++ 列出 sqlserver 的所有实例。

如何在 C++ 中使用 smo 库来做到这一点? 给我代码示例。

提前致谢..

I am trying to list all the instances of sqlserver using c++ in vs2005.

How to do this using smo library in c++? give me code example.

Thanks in advance..

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我早已燃尽 2024-07-31 06:49:16

使用 Windows Toolhelp API,您可以枚举 SQL Server 进程,而无需使用 SQL API(我没有查看)。

  • 您可以使用 CreateToolhelp32Snapshot 调用创建系统快照。
  • 使用 Process32Next 和 Process32First 循环执行快照进程。
  • 对于每个进程,查询 PROCESSENTRY32 结构成员。 szExeFile 包含可执行文件名。

请注意,服务在 services.exe 可执行文件下运行,因此如果您的服务器作为服务运行,则可能无法使用此方法看到它。

Using the Windows Toolhelp API, you can enumerate the SQL Server processes, this without using the SQL API (which I didn't look).

  • You create a snapshot of your system with CreateToolhelp32Snapshot call.
  • Use Process32Next and Process32First to cycle through the snapshot processes.
  • With each process, query the PROCESSENTRY32 struct members. szExeFile contains the executable filename.

Note that services run under the services.exe executable so if your server is running as service maybe you won't see it with this method.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文