<分区>
我正在尝试将一些 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 */
};
此外,这个对象 scx 在 ntfs_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/
相关文章:
python - 用 cython 包装 C++ 类,让基本示例正常工作
c++ - 从 std::system 调用执行时,awk 的输出重定向失败
c++ - 为什么 Createfile() 没有二进制标志
c++ - 文件如何进入 Visual Studio C++ 中的外部依赖项?
c++ - QNetworkConfigurationManager::allConfigurations() 没有列出 WLAN
windows - 如何将\\wsl$\type unc 路径映射到 Windows 驱动器号?
c - 什么是预处理器定义禁用警告 "GetVersionExW' : was declared deprecated"