winapi - Using a win32 DLL library on a Universal Windows App C++ -


i able compile dll library based following instructions indicated tutorial http://tutplusplus.blogspot.com/2011/04/c-tutorial-create-dll-in-vc-20102008.html. compiled , there no problems. tested dll library on empty win32 console application solution , compiled fine adding header, source file , changing linker settings. problem can't use dll library time on universal windows app solution. added header , source files changed linker settings.

when compiled project solution asked me include pch.h source file of library added line #include "pch.h" on top.

after that, other compiler errors came up.

'createfile': identifier not found , 'setcommstate': identifier not found

i believe compiler current project solution recompiled everything again without considering dll library's compilation. how can make project solution compile own source , header files?

lib header:

#pragma once #include <windows.h>  namespace nmspace {     class serialport      {     public:         static __declspec(dllexport) int connect();     }; } 

lib source:

#include <iostream> using namespace std; #include "simpleh.h" #include <windows.h>  namespace nmspace {     int serialport::connect()      {         int error = 0;         dcb dcb;          memset(&dcb, 0, sizeof(dcb));          dcb.dcblength = sizeof(dcb);          dcb.baudrate = 57600;         dcb.parity = noparity;         dcb.fparity = 0;         dcb.stopbits = onestopbit;         dcb.bytesize = 8;          handle m_serialporthandle = createfile(l"com7", generic_read | generic_write, 0, null, open_existing, null, null);          if (m_serialporthandle != invalid_handle_value) {             if (!setcommstate(m_serialporthandle, &dcb))                 error = 2;         }         else             error = 1;          return error;     }  } 

you won't able use dll because uses setcommstate function available desktop applications. should lookup functions trying use in list of desktop apis available uwp applications.

as createfile not function, macro expanding createfilea or createfilew depending on project unicode settings. should use createfile2 instead available both desktop , uwp applications.


Comments

Popular posts from this blog

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -