void TSysInfoWindow::GetSysInformation( void )
{
	DWORD SysFlags;
	char tempstr[ 31 ];
	WORD ArgList[ 2 ];
	WORD Ver;
	DWORD Available;
	HINSTANCE hInstance = GetApplication()->hInstance;

	SysFlags = GetWinFlags();

	ArgList[ 0 ] = GetModuleUsage( hInstance );
	wvsprintf( (LPSTR) TransferRecord.InstanceNumber, (LPSTR) "%d", (LPSTR) ArgList );

	Ver = GetVersion();
	ArgList[0] = (WORD) LOBYTE(LOWORD( Ver ));
	ArgList[1] = (WORD) HIBYTE(LOWORD( Ver ));
	wvsprintf( (LPSTR) TransferRecord.WindowsVersion, (LPSTR) "%d.%d", (LPSTR) ArgList );

	if ( SysFlags & WF_ENHANCED )
		LoadString( hInstance, ID_ENHANCED, tempstr, sizeof( tempstr ) );
	else if ( SysFlags & WF_STANDARD )
		LoadString( hInstance, ID_STANDARD, tempstr, sizeof( tempstr ) );
	else if ( SysFlags & WF_PMODE )
		LoadString( hInstance, ID_REAL, tempstr, sizeof( tempstr ) );
	else
		LoadString( hInstance, ID_UNKNOWN, tempstr, sizeof( tempstr ) );
	strcpy( TransferRecord.OperationMode, tempstr );

	if ( SysFlags & WF_CPU086 )
		LoadString( hInstance, ID_CPU8086, tempstr, sizeof( tempstr ) );
	else if ( SysFlags & WF_CPU186 )
		LoadString( hInstance, ID_CPU80186, tempstr, sizeof( tempstr ) );
	else if ( SysFlags & WF_CPU286 )
		LoadString( hInstance, ID_CPU80286, tempstr, sizeof( tempstr ) );
	else if ( SysFlags & WF_CPU386 )
		LoadString( hInstance, ID_CPU80386, tempstr, sizeof( tempstr ) );
	else if ( SysFlags & WF_CPU486 )
		LoadString( hInstance, ID_CPU80486, tempstr, sizeof( tempstr ) );
	else
		LoadString( hInstance, ID_UNKNOWN, tempstr, sizeof( tempstr ) );
	strcpy( TransferRecord.CPUType, tempstr );

	if ( SysFlags & WF_80x87 )
		LoadString( hInstance, ID_YES, tempstr, sizeof( tempstr ) );
	else
		LoadString( hInstance, ID_NO, tempstr, sizeof( tempstr ) );
	strcpy( TransferRecord.CoProcessor, tempstr );

	Available = GetFreeSpace( 0 ) / 1024;
	ArgList[0] = LOWORD( Available );
	ArgList[1] = HIWORD( Available );
	wvsprintf( (LPSTR) TransferRecord.Global, (LPSTR) "%lu", (LPSTR) ArgList );

	ArgList[0] = _osmajor;
	ArgList[1] = _osminor;
	wvsprintf( (LPSTR) TransferRecord.VersionDos, (LPSTR) "%d.%d", (LPSTR) ArgList );

	TransferBuffer = (LPSTR) &TransferRecord;
}
Ejemplo n.º 2
0
int PASCAL WinMain(HINSTANCE hInst,
  HINSTANCE /*hPrevInst*/, LPSTR /*pszCmdLine*/,
  int /*nCmdShow*/)
{
    if (IsWin95())
    {
        if (GetModuleUsage(hInst) <= 1)
            SetModuleExpWinVer(hInst, 0x0400);
        SetTaskExpWinVer(GetCurrentTask(), 0x0400);
    }

    // do something else...

    if (IsWin95())
    {
        if (GetModuleUsage(hInst) <= 1)
            SetModuleExpWinVer(hInst, 0x030a);
        SetTaskExpWinVer(GetCurrentTask(), 0x030a);
    }
    return (0);
}
Ejemplo n.º 3
0
    static int
mch_system(char *cmd, int options)
{
    DWORD		ret = 0;
    UINT		wShowWindow;
    UINT		h_module;
    MSG			msg;
    BOOL		again = TRUE;

    /*
     * It's nicer to run a filter command in a minimized window, but in
     */
    if (options & SHELL_DOOUT)
	wShowWindow = SW_SHOWMINIMIZED;
    else
	wShowWindow = SW_SHOWNORMAL;

    /* Now, run the command */
    h_module = WinExec((LPCSTR)cmd, wShowWindow);

    if (h_module < 32)
    {
	/*error*/
	ret = -h_module;
    }
    else
    {
	/* Wait for the command to terminate before continuing */
	while (GetModuleUsage((HINSTANCE)h_module) > 0 && again )
	{
	    while( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) && again )
	    {
		if(msg.message == WM_QUIT)

		{
		    PostQuitMessage(msg.wParam);
		    again = FALSE;
		}
		TranslateMessage(&msg);
		DispatchMessage(&msg);
	    }
	}
    }

    return ret;
}
Ejemplo n.º 4
0
/* NOTES:
 *   For Win16, programmers generally use WINAPI WinMain(...) but WINAPI is defined in such a way
 *   that it always makes the function prolog return FAR. Unfortunately, when Watcom C's runtime
 *   calls this function in a memory model that's compact or small, the call is made as if NEAR,
 *   not FAR. To avoid a GPF or crash on return, we must simply declare it PASCAL instead. */
int PASCAL WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow) {
	WNDCLASS wnd;
	MSG msg;

	myInstance = hInstance;

#if TARGET_MSDOS == 16 && TARGET_WINDOWS < 31 /* Windows 3.0 or older (any version capable of real-mode) */
    /* our data segment is discardable.
     * in Windows 3.0 real mode that means our data segment can disappear out from under us.
     * unfortunately I don't know how to call the data segment back in.
     * so we have to compensate by locking our data segment in place. */
    LockData();
#endif

	/* FIXME: Windows 3.0 Real Mode: Why are we unable to load our own Application Icon? */
	AppIcon = LoadIcon(hInstance,MAKEINTRESOURCE(IDI_APPICON));
	if (!AppIcon) MessageBox(NULL,"Unable to load app icon","Oops!",MB_OK);

#ifdef WIN16_NEEDS_MAKEPROCINSTANCE
	WndProc_MPI = MakeProcInstance((FARPROC)WndProc,hInstance);
#endif

	/* NTS: In the Windows 3.1 environment all handles are global. Registering a class window twice won't work.
	 *      It's only under 95 and later (win32 environment) where Windows always sets hPrevInstance to 0
	 *      and window classes are per-application.
	 *
	 *      Windows 3.1 allows you to directly specify the FAR pointer. Windows 3.0 however demands you
	 *      MakeProcInstance it to create a 'thunk' so that Windows can call you (ick). */
	if (!hPrevInstance) {
		wnd.style = CS_HREDRAW|CS_VREDRAW;
#ifdef WIN16_NEEDS_MAKEPROCINSTANCE
		wnd.lpfnWndProc = (WNDPROC)WndProc_MPI;
#else
		wnd.lpfnWndProc = WndProc;
#endif
		wnd.cbClsExtra = 0;
		wnd.cbWndExtra = 0;
		wnd.hInstance = hInstance;
		wnd.hIcon = AppIcon;
		wnd.hCursor = NULL;
		wnd.hbrBackground = NULL;
		wnd.lpszMenuName = NULL;
		wnd.lpszClassName = WndProcClass;

		if (!RegisterClass(&wnd)) {
			MessageBox(NULL,"Unable to register Window class","Oops!",MB_OK);
			return 1;
		}
	}

	HelloMsg();

	hwndMain = CreateWindow(WndProcClass,"Hello!",
		WS_OVERLAPPEDWINDOW,
		CW_USEDEFAULT,CW_USEDEFAULT,
		300,200,
		NULL,NULL,
		hInstance,NULL);
	if (!hwndMain) {
		MessageBox(NULL,"Unable to create window","Oops!",MB_OK);
		return 1;
	}

	ShowWindow(hwndMain,nCmdShow);
	UpdateWindow(hwndMain); /* FIXME: For some reason this only causes WM_PAINT to print gibberish and cause a GPF. Why? And apparently, Windows 3.0 repaints our window anyway! */

	while (GetMessage(&msg,NULL,0,0)) {
		TranslateMessage(&msg);
		DispatchMessage(&msg);
	}

#if TARGET_MSDOS == 16
    /* Win16 only:
     * If we are the owner (the first instance that registered the window class),
     * then we must reside in memory until we are the last instance resident.
     * If we do not do this, then if multiple instances are open and the user closes US
     * before closing the others, the others will crash (having pulled the code segment
     * behind the window class out from the other processes). */
	if (!hPrevInstance) {
        while (GetModuleUsage(hInstance) > 1) {
            PeekMessage(&msg,NULL,0,0,PM_REMOVE);
            TranslateMessage(&msg);
            DispatchMessage(&msg);
        }
    }
#endif

	return msg.wParam;
}