Thread overview
Win32API: core.sys.windows: every argument name is missing.
Nov 29
BoQsc
Nov 30
DrDread
Nov 30
BoQsc
Dec 01
Kagamin
November 29

What should be done? What is expected?

How it is currently in the core/sys/windows/winbase.d:

 BOOL WriteFile(HANDLE, PCVOID, DWORD, PDWORD, LPOVERLAPPED);

How it should be according to Win32 API documentation:

BOOL WriteFile(
	HANDLE hFile,
	PCVOID lpBuffer,
	DWORD nNumberOfBytesToWrite,
	PDWORD lpNumberOfBytesWritten,
	LPOVERLAPPED lpOverlapped
);

The names: hFile, lpBuffer, nNumberOfBytesToWrite, lpNumberOfBytesWritten, lpOverlapped are missing.

Why it is important?

Without named arguments you can not use : syntax to set arguments in the function call.

	WriteFile(
		hFile: GetStdHandle(STD_OUTPUT_HANDLE),

It is important if you want your interfacing code to be more readable.

Here is a quick example with : and extern that corrects the winbase.d definition to allow : inside function call.

import core.sys.windows.winbase : GetStdHandle, STD_OUTPUT_HANDLE;

extern(Windows) {
	import core.sys.windows.basetsd : HANDLE;
	import core.sys.windows.windef  : BOOL, PCVOID, DWORD, PDWORD;
	import core.sys.windows.winbase : LPOVERLAPPED;

	BOOL WriteFile(HANDLE hFile, PCVOID lpBuffer, DWORD nNumberOfBytesToWrite, PDWORD lpNumberOfBytesWritten, LPOVERLAPPED lpOverlapped);
}

void main(){
	string message = "Welcome to D";
	uint bytesWritten;

	WriteFile(
		hFile: GetStdHandle(STD_OUTPUT_HANDLE),
		lpBuffer: message.ptr,
		nNumberOfBytesToWrite: message.length,
		lpNumberOfBytesWritten: &bytesWritten,
		lpOverlapped: null
	);
}
November 30

On Wednesday, 29 November 2023 at 14:59:40 UTC, BoQsc wrote:

>

What should be done? What is expected?

[...]

I 100% support your request. please add those names. makes IDE support so much more useful if i can see what the parameter is supposed to do

November 30

If I'm not mistaken, reviving the idea of windows-d project would allow to generate Windows Headers in a more automated standard way.

By inspecting the example output it seems to be promising thing, if introduced into D Lang ecosystem. Replacing the old Public Domain handwritten MinGW reverse-engineered header translations.


link to the source code seen in the image

Related article:
https://blogs.windows.com/windowsdeveloper/2021/01/21/making-win32-apis-more-accessible-to-more-languages/

December 01

On Thursday, 30 November 2023 at 11:49:26 UTC, BoQsc wrote:

>

If I'm not mistaken, reviving the idea of windows-d project would allow to generate Windows Headers in a more automated standard way.

This is a known issue. One of the goals of ImportC is to make it possible to import the Windows headers in a completely automated way. We'll never be able to import all of the headers due to some of the strangeness in them, but we should be able to get most of them. ImportC generated DI files do include the parameter names.

Another deficiency of these files is that they are from the Windows Vista/7 era and are missing large chunks of the modern Windows API.

If you want to try ImportC on windows headers I'd be curious to hear how it goes, and please file bugs!

December 01

see https://forum.dlang.org/post/swmmlsaoefhrtansanfy@forum.dlang.org

December 01

On Friday, 1 December 2023 at 06:20:33 UTC, Adam Wilson wrote:

>

On Thursday, 30 November 2023 at 11:49:26 UTC, BoQsc wrote:

>

If I'm not mistaken, reviving the idea of windows-d project would allow to generate Windows Headers in a more automated standard way.

This is a known issue. One of the goals of ImportC is to make it possible to import the Windows headers in a completely automated way. We'll never be able to import all of the headers due to some of the strangeness in them, but we should be able to get most of them.

I fear that “most” is not good enough. You either have 100% correct binding or be prepared to debug the missing pieces instead of writing your application.

——
Dmitry Olshansky

December 02

On Friday, 1 December 2023 at 09:43:57 UTC, Dmitry Olshansky wrote:

>

I fear that “most” is not good enough. You either have 100% correct binding or be prepared to debug the missing pieces instead of writing your application.

——
Dmitry Olshansky

That's not significantly different or worse from the present situation where all of the APIs from any version of Windows after 7 are simply missing.