CreateFile library error - Printable Version +- QB64 Phoenix Edition (https://qb64phoenix.com/forum) +-- Forum: QB64 Rising (https://qb64phoenix.com/forum/forumdisplay.php?fid=1) +--- Forum: Code and Stuff (https://qb64phoenix.com/forum/forumdisplay.php?fid=3) +---- Forum: Help Me! (https://qb64phoenix.com/forum/forumdisplay.php?fid=10) +---- Thread: CreateFile library error (/showthread.php?tid=1731) |
RE: CreateFile library error - eoredson - 06-06-2023 That's even more confusing. I am also using _unsigned long for functions concerning attribute returns. Do I have to modify them as well? RE: CreateFile library error - DSMan195276 - 06-06-2023 (06-06-2023, 03:43 AM)eoredson Wrote: That's even more confusing. I am also using _unsigned long for functions concerning attribute returns.You simply need to read the Microsoft documentation and understand the C++ types used. See the CreateFileA description. `DWORD` is a 32-bit integer, which in QB64 is a `LONG`. `LPCSTR` is a string pointer, and translates to a `String` in QB64 (passed by reference, but that's the default). `LPSECURITY_ATTRIBUTES` is a pointer (LP), so it should be an `_Offset`. And `HANDLE` is a typedef for a `void *`, so in QB64 it should be an `_Offset`. As a separate question, is there a reason you're trying to use `CreateFileA` and other Win32 APIs in the first place? The best way to make your program cross platform is to simply avoid using any `Declare Library` or Win32 APIs, and just use built-in commands like `OPEN` to create files. If you're not comfortable understanding the C++ types then you're likely to just keep running into issues trying to use Win32 APIs. They're all intended for being used in C++ code, not QB64, you can call them but you need C++ knowledge to really do it properly. RE: CreateFile library error - eoredson - 06-06-2023 What if I am using the following to get a filename/directory attribute: Does this throw a 64-bit compilation error as well? Code: (Select All) Rem $Dynamic RE: CreateFile library error - eoredson - 06-06-2023 I need to know because I might have the same problem with GetFileAttribute as I do with CreateFile.. Erik. RE: CreateFile library error - Ultraman - 06-06-2023 I'd recommend using Declare CustomType Library instead. Or, if you want to avoid compilation errors entirely, declare the DLL that contains that function rather than trying to use the headers. RE: CreateFile library error - DSMan195276 - 06-06-2023 (06-06-2023, 06:06 AM)Ultraman Wrote: I'd recommend using Declare CustomType Library instead. Or, if you want to avoid compilation errors entirely, declare the DLL that contains that function rather than trying to use the headers.I would definitely not recommend that. In this case all `CustomType` would do is allow you to ignore the C++ function declaration already present from the header, you should only do that if it's necessary. In this case, the compilation error is because eoredson had a legitimate bug in his program and as a consequence it would not work on 64-bit. Using `CustomType` would have allowed it to compile, but not actually fix the bug. It provides a false sense of security and you shouldn't be using it unless actually necessary. (06-06-2023, 04:29 AM)eoredson Wrote: I need to know because I might have the same problem with GetFileAttribute as I do with CreateFile..Again, read the Microsoft documentation, it tells you the exact information you're looking for. The GetFileAttributeA function documentation is here. The provided syntax is this: Code: (Select All) DWORD GetFileAttributesA( RE: CreateFile library error - Ultraman - 06-07-2023 I guess the many, many times I've used Declare CustomType Library with zero issues have all been flukes. RE: CreateFile library error - DSMan195276 - 06-07-2023 (06-07-2023, 09:44 PM)Ultraman Wrote: I guess the many, many times I've used Declare CustomType Library with zero issues have all been flukes.I'm not saying CustomType is always the wrong thing to use, there are times when it's necessary, what I'm saying is that it's the wrong thing to use here because it doesn't solve the actual problem. CustomType just lets you ignore the C++ types, it doesn't actually fix your declaration to have the right types. In cases like this one the C++ types are quite helpful because they identify if you're passing the right types at compile time and avoid having to debug runtime issues. Adding CustomType to eroedson's original code wouldn't have made it work correctly, it would have just allowed it to compile. RE: CreateFile library error - eoredson - 06-08-2023 According to Google a DWORD is a unsigned 32-bit which in QB64 is declared as _Unsigned Long so therefore I don't need to change any calls to Function GetFileAttributes lucky enough!? Erik. RE: CreateFile library error - eoredson - 06-08-2023 Windows 64-bit applications: Name/Length/QB64 ---------------------- WORD/2 bytes/Integer DWORD/4 bytes/Long or _offset HANDLE/8 bytes/_Integer64 or _offset HFILE/4 bytes/Long https://www.ibm.com/docs/en/ibm-mq/7.5?topic=platforms-standard-data-types |