这样做合法吗?我想导出一个 C 函数,但在内部该函数将使用一个 C++ 类。
extern "C" BOOL /*BOOL==int*/ Func()
{
return someclass::getinstance()->Func(); // this is just bool tho
}
Run Code Online (Sandbox Code Playgroud) 我想知道我是否在这里重新发明轮子.
实质上,新的Common Item Dialog文件浏览器比旧的GetOpenFileName()版本好得多.如果用户在Vista +操作系统上,我想使用新的对话框,但仍然具有XP上旧对话框的功能等.
所以我想知道我是否应该创建这样的函数.
BOOL ShowOpenFileDialog(_Out_ LPTSTR szBuffer, _In_ UINT iBufferSize)
{
static DWORD dwMajorVersion = 0;
if (!dwMajorVersion)
dwMajorVersion = (DWORD)(LOBYTE(LOWORD(GetVersion())));
if (dwMajorVersion >= 6) // Vista+
return ShowNewOpenFileDialog(szBuffer, iBufferSize); // show common item
return ShowOldOpenFileDialog(szBuffer, iBufferSize); // fall back to old dialog
}
Run Code Online (Sandbox Code Playgroud)
另外一个跟进是C++的常用项目吗?