VC6 and Win95 WinAPI 
Author Message
 VC6 and Win95 WinAPI

I'm by no means an expert Windows developer but I have made a few programs
in the past. I recently installed VC6 at home on a Win95 machine and am
currently trying to make a test program to make sure its working right. Its
a simple little straight C program using WinAPI to register a class and then
create a window using it. But, however simple it may be, the compiled EXE
fails to run on my machine. The RegisterClass function fails returning 0. An
immediate call to GetLastError also returns 0. Perplexing enough in its own
right as GetLastError returning 0 is supposed to mean successful completion
of the operation, but when I called FormatMessage with GetLastError, the
first few result messages seemed to indicate that I was running 16-bit and
thus the 32-bit functions would not work. This seems to fit with the
function description for GetLastError which states that it will not work
with 32-bit functions called from 16-bit code. When I ran it through the
de{*filter*} I got the same results but in the Output window where it lists the
loaded DLLs, beside each of them was the message 'no matching symbolic
information found'.

My question is, why does it think my code is 16-bit? The CD Jewel for VC6
states it was designed for WinNT and Win98, is Win95 just not supported (aka
treated as 16-bit)? Or is this a problem fixed by VC SP1 (which I am
downloading (all 42.5 MB of it) as I type)? Any ideas as to what might be
going wrong (linker settings, code flaws, missing files, etc) would be
greatly appreciated.

Thanks,
Mike Lipari



Wed, 27 Jun 2001 03:00:00 GMT  
 VC6 and Win95 WinAPI

Quote:

>I'm by no means an expert Windows developer but I have made a few programs
>in the past. I recently installed VC6 at home on a Win95 machine and am
>currently trying to make a test program to make sure its working right. Its
>a simple little straight C program using WinAPI to register a class and then
>create a window using it. But, however simple it may be, the compiled EXE
>fails to run on my machine. The RegisterClass function fails returning 0. An
>immediate call to GetLastError also returns 0. Perplexing enough in its own
>right as GetLastError returning 0 is supposed to mean successful completion
>of the operation, but when I called FormatMessage with GetLastError, the
>first few result messages seemed to indicate that I was running 16-bit and
>thus the 32-bit functions would not work. This seems to fit with the
>function description for GetLastError which states that it will not work
>with 32-bit functions called from 16-bit code. When I ran it through the
>de{*filter*} I got the same results but in the Output window where it lists the
>loaded DLLs, beside each of them was the message 'no matching symbolic
>information found'.

>My question is, why does it think my code is 16-bit? The CD Jewel for VC6
>states it was designed for WinNT and Win98, is Win95 just not supported (aka
>treated as 16-bit)? Or is this a problem fixed by VC SP1 (which I am
>downloading (all 42.5 MB of it) as I type)? Any ideas as to what might be
>going wrong (linker settings, code flaws, missing files, etc) would be
>greatly appreciated.

>Thanks,
>Mike Lipari

Please show the code..it may be useful

-----------------** -- Posted from CodeGuru -- **-----------------
http://www.*-*-*.com/ ;  The website for Visual C++ programmers.



Wed, 27 Jun 2001 03:00:00 GMT  
 VC6 and Win95 WinAPI
It would be much easier to verify the correctness of your code if you
initialized the members of WNDCLASS in the same order that they
are declared. Once you do that it becomes obvious that cbClsExtra
is never initialized. That might be your problem.

You could also avoid this problem, simplify your code, and avoid a
possible memory leak by declaring your WNDCLASS by going:

WNDCLASS wcMainClass = {0};

I hope this helps. BTW - VC++ 6.0 does not produce 16 bit code.
LastError not being set probably just means that RegisterClass
forgets to set it for this specific error. There are a few functions that
do that, and it's always annoying.

Quote:

> |Please show the code..it may be useful
> |

> I had hoped for a simple 'Oh, sounds like you need to set your linker to
> blahblah blah' but here is the code anyway. It follows in text form as well
> as as an attachment. I know it as of yet does nothing (not even creating the
> window or the message loop), but the class should still be able to register.
> Or at least not fail with an error of 0.

> code follows ==>

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

> LRESULT CALLBACK PBNMainWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM
> lParam);

> int WINAPI WinMain(HINSTANCE hinst, HINSTANCE hprevinst, LPSTR cmdLine, int
> sFlag)
> {
>  WNDCLASS *wcMainclass;
>  char msg[500];
>  int temp, temp2;

>  //Register main window class.
>  wcMainclass = (WNDCLASS *) malloc(sizeof(WNDCLASS));
>  wcMainclass->cbWndExtra = 0;
>  wcMainclass->hbrBackground = (HBRUSH) COLOR_BACKGROUND;
>  wcMainclass->hCursor = LoadCursor(hinst, IDC_ARROW);
>  wcMainclass->hIcon = NULL; //(HICON) IDI_SMPBNICON;
>  wcMainclass->hInstance = hinst;
>  wcMainclass->lpfnWndProc = PBNMainWndProc;
>  wcMainclass->lpszClassName = "PBNCLS";
>  wcMainclass->lpszMenuName = NULL;
>  wcMainclass->style = CS_DBLCLKS | CS_VREDRAW | CS_HREDRAW;
>  if ((temp2 = RegisterClass(wcMainclass)) == 0)

--
.Bruce Dawson, Cavedog Entertainment.
Makers of Total Annihilation - http://www.cavedog.com


Mon, 02 Jul 2001 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. VC6 and Win95 WinAPI

2. Building on Win95 for WinNT in VC6

3. Installing VC6 apps under Win95

4. Seeking -Win95 programmer- for a custom simple win95 prg

5. Is it possible to convert my German VC6.0 to an English VC6.0

6. Winapi class library

7. access winapi constants using c#

8. Translating WinAPI oledraw to C#

9. WINAPI problems

10. progress indicator in winapi

11. winAPI code

12. C# Newbie WinApi help

 

 
Powered by phpBB® Forum Software