<byte>Array^ in Win32
Array<byte>^ in Win32
我有一个为Metro风格编写的DirectX 11.1程序,我想将其转换为Win32应用程序。我使用过很多 WinRT 库,其中大多数都是为 HWND 建立的。但我仍然有一个问题:
在地铁风格应用程序上,为了使用 HLSL 文件,这就是我使用的:
inline Platform::Array<byte>^ ReadFile(Platform::String^ path)
{
using namespace Platform;
Array<byte>^ bytes = nullptr;
FILE* f = nullptr;
_wfopen_s(&f, path->Data(), L"rb");
if (f == nullptr)
{
throw ref new Exception(0, "Could not open file on following path : " + path);
}
else
{
fseek(f, 0, SEEK_END);
auto pos = ftell(f);
bytes = ref new Array<byte>(pos);
fseek(f, 0, SEEK_SET);
// read data into the prepared buffer
if (pos > 0)
{
fread(&bytes[0], 1, pos, f);
}
// close the file
fclose(f);
}
return bytes;
}
但我不知道 Win32 (hwnd) 风格应用程序的数组Array<byte>^
的等效项。高度赞赏任何指南
我们可以用std::vector<unsigned char>
代替:
std::vector<unsigned char> ReadFile(std::wstring path)
{
std::vector<unsigned char> bytes;
...
_wfopen_s(&f, path.c_str(), L"rb");
...
bytes.resize(pos);
...
fread(bytes.data(), 1, pos, f);
...
return bytes;
}
相关文章:
- netcat command in c++
- Difference in displaying cv2 Mat
- Win32编译器选项和内存分配
- C++ MFC Libraries in Travis CI
- 如何在OpenSSL中从configuration.h.in获取configuration.h
- C++win32 API创建多个类似视口的窗口
- WM_CTLCOLORSTATIC从未在WIN32应用程序中触发
- 创建具有 new in 函数和"this is nullptr"异常的对象
- IN, OUT, INOUT Parameters
- 检测win32服务创建和删除的最佳方法
- 应用程序崩溃并显示"symbol _ZdlPvm, version Qt_5 not defined in file libQt5Core.so.5 with link time reference"
- WIN32:C++,为什么在WM_CLOSE上调用Messagebox函数程序正在冻结
- 有人安装"IITB Simplecpp in mac"吗?
- 从 C 样式字符串中删除子字符串 "in place" 在C++代码中
- 将 win32 hbitmap 转换为 winrt softwarebitmap
- 如何修复"error: ‘_1’ was not declared in this scope"?
- 使用 WIN32 API (C/C++) 对特定树视图项进行着色
- Alt+Enter 在 Win32 应用中,管理大小调整和分辨率
- <byte>Array^ in Win32
- C# DateTime.ToUniversalTime() in C++ Win32