【发布时间】:2020-01-13 12:12:07
【问题描述】:
我正在尝试将一些 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 系统那样具有“组”,因此在 Windows 中没有等效的功能。
-
您是否需要打印“组”ID?原程序在做什么?
-
你只是在谈论力学。你应该做的是捕捉逻辑。您需要首先回答几个问题:源应用程序对这些信息做了什么?可以将这种用法转换为更通用的概念吗?你能把这个概念翻译到 Windows 上吗?在你得到这些问题的答案之前,不要编写任何代码。
-
由于我们不知道它的用途或程序在做什么,所以我们真的无从得知。
-
"... 到 ntfs_build_mapping 函数中。这个函数是 NTFS Linux 库的一部分..." 因为 NTFS 是 MS-Windows 原生的,首先要删除这一层 .. . 你的其他问题我就消失了。
标签: c++ windows winapi visual-c++ mfc