c++ - `CreateFile` for UWP in visual studio not available in <Windows.h>? -
still familiarizing myself vs, wanted use method createfile
in 1 of source files uwp app building compiler says 'createfile': identifier not found...
included header <windows.h>
. tried in console application template , works. suggestions?
header:
#pragma once #include <windows.h> #include <string> #include "pch.h" typedef std::basic_string<tchar> tstring; class serial { public: serial(tstring &commportname, int bitrate = 115200); ~serial(); private: handle commhandle; int write(const char *buffer); };
source:
#include "pch.h" #include "serial.h" serial::serial(tstring &commportname, int bitrate) { commhandle = createfile(commportname.c_str(), generic_read | generic_write, 0, null, open_existing, 0, null); } serial::~serial() { closehandle(commhandle); } int serial::write(const char *buffer) { dword numwritten; writefile(commhandle, buffer, strlen(buffer), &numwritten, null); return numwritten; }
you should use serialdevice
class open port in uwp.
https://docs.microsoft.com/en-us/uwp/api/windows.devices.serialcommunication.serialdevice
Comments
Post a Comment