c++ - Win32 相当于 getgid

标签 c++ windows winapi visual-c++ mfc

<分区>


想改进这个问题吗? 通过 editing this post 添加细节并澄清问题.

关闭 3 年前

我正在尝试将一些 C Linux 代码转换为 Win32 C++。我有 getgid 功能。如何将此 Linux C 函数转换为 Win32?

这是getgid的文档:http://man7.org/linux/man-pages/man2/getgid.2.html

这里是使用上下文:

struct SEC_CONTEXT* scx;
scx->gid = getgid();

其中 SEC_CONTEXT 定义为:

struct SEC_CONTEXT {
ntfs_volume* vol;
gid_t gid; /* gid of user requesting (not the mounter) */
pid_t tid; /* thread id of thread requesting */
};

此外,这个对象 scxntfs_mapping 函数内部使用,等等……而 git_t 是一个简单的 无符号整数

最佳答案

Windows 没有 POSIX 进程组的概念。使该代码可移植需要了解码 ID 的用途。

不过,作为灵感,GnuWin 是如何实现它的:

/* Get the real group ID of the calling process.  */
gid_t
__getgid ()
{
  return 0;
}

一个更有用的值是通过getpgid获得的,因为默认情况下,windows按照父PID对进程进行分组;因此组 ID 等于进程 ID 值。

关于c++ - Win32 相当于 getgid,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59716461/

上一篇:c++ - 如何在MFC中的静态文本控件上插入图标?

下一篇:c++ - QT如何将Qlist传递给类构造函数

相关文章:

python - 用 cython 包装 C++ 类,让基本示例正常工作

c++ - 使用 openGL 的常规窗口屏幕捕获

c++ - 从 std::system 调用执行时,awk 的输出重定向失败

c++ - 为什么 Createfile() 没有二进制标志

c++ - 文件如何进入 Visual Studio C++ 中的外部依赖项?

c++ - 结构指针的区别

c++ - QNetworkConfigurationManager::allConfigurations() 没有列出 WLAN

windows - 如何将\\wsl$\type unc 路径映射到 Windows 驱动器号?

c# - 如何从不同应用程序的窗口控件中读取数据?

c - 什么是预处理器定义禁用警告 "GetVersionExW' : was declared deprecated"