Hi,
I am getting a syntax error :

\Sainath.C(24) : error C2059: syntax error : '__stdcall'


for the below code:

int main()
{

COORD WINAPI GetLargestConsoleWindowSize(
  __in  HANDLE hConsoleOutput
);

printf("%d",x.WINAPI);

// I know its the printf statement which is wrong as only when I wrote it I got the error

mainMenu();
return 0;
}

Please advice what is wrong with the syntax.

Recommended Answers

All 9 Replies

just delete line 4, 5 and 6 because it is defined in windows.h (wincon.h)

>>printf("%d",x.WINAPI);
what is x.WINAPI?

>>Please advice what is wrong with the syntax
Everything. WINAPI is not a data object that can be printed.

just delete line 4, 5 and 6 because it is defined in windows.h (wincon.h)

>>printf("%d",x.WINAPI);
what is x.WINAPI?

>>Please advice what is wrong with the syntax
Everything. WINAPI is not a data object that can be printed.

Hi,
I corrected the code and now its able to compile and I am able to make the exe file.
but I get an out put of as 00 when I execute it. I am confused as it should give me the size of the Largest Console.

Where is my logic wrong ?

HANDLE hCponsoleOutput;
COORD NEW=GetLargestConsoleWindowSize(hCponsoleOutput);
printf("%d",NEW.X);
printf("%d",NEW.Y);

Here's the correction

int main()
{
   HANDLE hStdout = GetStdHandle(STD_OUTPUT_HANDLE); 
COORD NEW=GetLargestConsoleWindowSize(hStdout);
printf("%d\n",NEW.X);
printf("%d\n",NEW.Y);

    
return 0;
}

Hi,
Thank you very much it works fine now.

I would like to know how do did you know that the function GetStdHandle(STD_OUTPUT_HANDLE) was needed ?

Please advice so that I learn to code more smartly.

Thank you.

Thanks, I read the manual on the website after your lead and I implemented the codes and I have no syntax error now but my goal to make the dos console to full screen is still not happening.

This is the below code but after I execute this code the dos console window does not take up the full screen. Please advice where I have gone wrong.

#include<stdio.h>
#include<windows.h>
#include <conio.h>

void main()
{
SMALL_RECT srctWindow;

HANDLE hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
COORD NEW=GetLargestConsoleWindowSize(hStdout);
printf("%d",NEW.X);
printf("\n\n\n\n");
printf("%d",NEW.Y);
printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
srctWindow.Top=NEW.X;
srctWindow.Bottom=NEW.Y;
srctWindow.Left=NEW.X;
srctWindow.Left=NEW.Y;

SetConsoleWindowInfo(hStdout,TRUE,&srctWindow);
printf("%d",srctWindow.Top);
printf("try");


}

Read this and this, please. They will help you in the long run.

If you are running Vista then read this thread

Hi,
I finally like the below solution as it was the best suited for what I wanted the funny thing is I found it in another thread in daniweb :)

#if (_WIN32_WINNT < 0x0500) // This switch is needed to make the program compile
#undef _WIN32_WINNT	    // because GetConsoleWindow needs it. See Documentation
#define _WIN32_WINNT 0x0500 // for GetConsoleWindow in MSDN.
#endif

#include <stdio.h>
#include <Windows.h> 


int main() 
{ 

	system("cls");

// NOTE: This method only works if the console window has the keyboard 
//       focus and the user isn't hitting keys on the keyboard.
    SetForegroundWindow(GetConsoleWindow()); 
    keybd_event(VK_MENU, MapVirtualKey(VK_MENU, 0), 0, 0); 
    keybd_event(VK_RETURN, MapVirtualKey(VK_RETURN, 0), 0, 0); 
    keybd_event(VK_RETURN, MapVirtualKey(VK_RETURN, 0), KEYEVENTF_KEYUP, 0); 
    keybd_event(VK_MENU, MapVirtualKey(VK_MENU, 0), KEYEVENTF_KEYUP, 0); 



return 0;
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.