1

I need to know how many arguments to pass in user32 and kernel32 functions for example :

windll.kernel32.GetConsoleTitle()

I get Error :

:ValueError: Procedure probably called with not enough arguments (4 bytes missing)

1
  • Welcome to Stack Overflow! Since you're new here, I recommend reading "How do I ask a good question?" for some tips. Your question is lacking sufficient detail to help the community help you. Commented Jan 27, 2018 at 16:28

2 Answers 2

1

You should read the API decscription. Here's the link for GetConsoleTitle: https://learn.microsoft.com/en-us/windows/console/getconsoletitle

DWORD WINAPI GetConsoleTitle(
  _Out_ LPTSTR lpConsoleTitle,
  _In_  DWORD  nSize
);

Update: Here's a short demo of getting console window title:

import ctypes
MAX_BUFFER = 260
title_text_buffer = (ctypes.c_char * MAX_BUFFER)()
res = ctypes.windll.kernel32.GetConsoleTitleA(title_text_buffer, MAX_BUFFER)
title_text = title_text_buffer.value
print title_text
Sign up to request clarification or add additional context in comments.

2 Comments

thank you @ababak, and where can i find other functions docs example user32, shell32 to learn it?
The link I've provided in my answer has other functions listed as well.
1

Tiny update to above code:

>>> import ctypes

>>> MAX_LEN = 256
>>> buffer_ = ctypes.create_unicode_buffer(MAX_LEN)
>>> ctypes.windll.kernel32.GetConsoleTitleW(buffer_, MAX_LEN)
5
>>> buffer_.value
'Command Prompt - python'

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.