Author Topic: New API functions?  (Read 7216 times)

felipe

  • Member
  • *****
  • Posts: 1381
New API functions?
« on: June 09, 2017, 03:21:53 PM »
Hi, i want to use the function SetConsoleDisplayMode, but is not defined in the kernel32.inc file. So what should i do to use that function?  :eusa_snooty:


jimg

  • Member
  • ***
  • Posts: 468
Re: New API functions?
« Reply #1 on: June 09, 2017, 03:47:48 PM »
it's in kernl32p

felipe

  • Member
  • *****
  • Posts: 1381
Re: New API functions?
« Reply #2 on: June 09, 2017, 11:34:06 PM »
it's in kernl32p

Thanks jimg. You are right, but in the system that dll doesn't exist, so how can i use those functions?  :eusa_snooty:

jj2007

  • Member
  • *****
  • Posts: 13857
  • Assembly is fun ;-)
    • MasmBasic
Re: New API functions?
« Reply #3 on: June 09, 2017, 11:44:57 PM »
Very old function but...

include \masm32\MasmBasic\MasmBasic.inc      ; download
  Init
  Dll "Kernel32"
  Declare void SetConsoleDisplayMode, 3
  SetConsoleDisplayMode(rv(GetStdHandle, STD_OUTPUT_HANDLE), CONSOLE_FULLSCREEN_MODE, 0)
  Print Err$()
  SetConsoleDisplayMode(rv(GetStdHandle, STD_OUTPUT_HANDLE), CONSOLE_WINDOWED_MODE, 0)
  Inkey Err$()
EndOfCode


Output:
Code: [Select]
Funzione non supportata dal sistema in uso.
Funzione non supportata dal sistema in uso.

felipe

  • Member
  • *****
  • Posts: 1381
Re: New API functions?
« Reply #4 on: June 09, 2017, 11:51:23 PM »
Very old function but...

include \masm32\MasmBasic\MasmBasic.inc      ; download
  Init
  Dll "Kernel32"
  Declare void SetConsoleDisplayMode, 3
  SetConsoleDisplayMode(rv(GetStdHandle, STD_OUTPUT_HANDLE), CONSOLE_FULLSCREEN_MODE, 0)
  Print Err$()
  SetConsoleDisplayMode(rv(GetStdHandle, STD_OUTPUT_HANDLE), CONSOLE_WINDOWED_MODE, 0)
  Inkey Err$()
EndOfCode


Output:
Code: [Select]
Funzione non supportata dal sistema in uso.
Funzione non supportata dal sistema in uso.

So is in fact an old dll that is omitted in the new windows versions?  :shock:

LiaoMi

  • Member
  • *****
  • Posts: 1051
Re: New API functions?
« Reply #5 on: June 09, 2017, 11:59:09 PM »
it's in kernl32p

Thanks jimg. You are right, but in the system that dll doesn't exist, so how can i use those functions?  :eusa_snooty:

This is not a dll, it's an add-on over kernel, to include these prototypes you need Inc and Lib files - https://msdn.microsoft.com/en-us/library/windows/desktop/ms686028(v=vs.85).aspx
You can try to load the library manually, with
       
LoadLibrary
GetModuleHandle
GetProcAddress

Or you can manually register a prototype - SetConsoleDisplayMode PROTO STDCALL :DWORD,:DWORD,:DWORD


jj2007

  • Member
  • *****
  • Posts: 13857
  • Assembly is fun ;-)
    • MasmBasic
Re: New API functions?
« Reply #6 on: June 10, 2017, 12:07:34 AM »
Try the attachment. You can't get any closer, since the console misbehaves - no fine-tuning with MoveWindow, unfortunately.

include \masm32\MasmBasic\MasmBasic.inc      ; download
  SetGlobals rc:RECT, py
  Init
  Dll "Kernel32"
  Declare void SetConsoleDisplayMode, 3
  SetConsoleDisplayMode(rv(GetStdHandle, STD_OUTPUT_HANDLE), CONSOLE_FULLSCREEN_MODE, 0)
  Print Err$()
  SetConsoleDisplayMode(rv(GetStdHandle, STD_OUTPUT_HANDLE), CONSOLE_WINDOWED_MODE, 0)
  Print Err$()
  ClearLastError
  invoke SystemParametersInfo, SPI_GETWORKAREA, 0, addr rc, 0
  invoke GetSystemMetrics, SM_CYCAPTION
  neg eax
  mov py, eax
  add rc.right, 6
  add rc.bottom, 6
  invoke MoveWindow, rv(GetConsoleWindow), -6, py, rc.right, rc.bottom, 1
  Inkey "better: ", Err$()
EndOfCode


Output:
Code: [Select]
Funzione non supportata dal sistema in uso.
Funzione non supportata dal sistema in uso.
better: Operazione completata.

felipe

  • Member
  • *****
  • Posts: 1381
Re: New API functions?
« Reply #7 on: June 10, 2017, 03:09:15 AM »
Thanks for your help. I tried what you said,  but i can't get it.  :(


jj2007

  • Member
  • *****
  • Posts: 13857
  • Assembly is fun ;-)
    • MasmBasic
Re: New API functions?
« Reply #8 on: June 10, 2017, 03:52:44 AM »
You will not get it. It's simply impossible for any Windows version starting with Vista. My code shows an approximation, but it remains a window... no full screen.

felipe

  • Member
  • *****
  • Posts: 1381
Re: New API functions?
« Reply #9 on: June 10, 2017, 03:55:09 AM »
Ok JJ, thanks for the reply, i think i should forget that function and go on.  :icon_mrgreen:

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 10558
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: New API functions?
« Reply #10 on: June 10, 2017, 10:23:47 AM »
 :biggrin:

Even Microsoft don't get it wrong all of the time, the console in Win 10 64 bit can be set at full screen and its a lot faster than even the console in Win7 64.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

jj2007

  • Member
  • *****
  • Posts: 13857
  • Assembly is fun ;-)
    • MasmBasic
Re: New API functions?
« Reply #11 on: June 10, 2017, 10:41:00 AM »
Right, I just checked on Win10: it works :dazzled:

felipe

  • Member
  • *****
  • Posts: 1381
Re: New API functions?
« Reply #12 on: June 10, 2017, 10:47:52 AM »
Yes, but in windows 8.1 it doesn't.

aw27

  • Guest
Re: New API functions?
« Reply #13 on: June 11, 2017, 05:44:59 AM »
:biggrin:

Even Microsoft don't get it wrong all of the time, the console in Win 10 64 bit can be set at full screen and its a lot faster than even the console in Win7 64.

I use ALT ENTER for full screen, and again to leave full screen. It works since XP.

jj2007

  • Member
  • *****
  • Posts: 13857
  • Assembly is fun ;-)
    • MasmBasic
Re: New API functions?
« Reply #14 on: June 11, 2017, 09:41:31 AM »
I use ALT ENTER for full screen, and again to leave full screen. It works since XP.

It works in XP and Win10, but not in Win7.