Unanswered C++/Win32 for the C# Programmer

  • Thursday, October 27, 2005 2:36 PM
     
     

    Hello, My name is Vincent and I did not know what a semaphore was (until recently).

    Recently I've noticed (and it's been pointed out to me) that my lack of C++ and the resulting lack of intimate knowledge of Win32 is not helping me as I continue to dive deeper into C# (and as the language matures).  Generics for instance have their roots in C++.  Concurrent programming in .Net is all about the OS.  I know and have studied the CLR abstraction of threading concepts (books, papers, code samples, etc) and have experience writing concurrent code but still I feel a little in the dark not knowing C++ and the intricacies of the OS.

    My background is Assembler and COBOL and there is a close parallel there; knowing Assembler was invaluable when I was writing and debugging COBOL programs.  Granted there is no comparison with what we had then to the tools available now around debugging, profiling/instrumenting Windows code.  I spent many a day staring at machine dumps and there was great satisfaction in being able to read that stuff.  Then came VB 4-6 and aside from the usual/customary poke into the Win32 API I was "protected" more or less from the nasty details; kind of like drilling for oil in a minefield.  The same thing seems to have happened now.  The abstraction afforded by the .Net Framework and CLR insulates us from most of these details.

    So better late than never; I want and need to really dig into Win32.  I saw Petzold's book on Amazon and it looks great, save for the fact the code samples are in C++.  I plan on getting this and attempting to work my way through;  hopefully it doesn't become just a huge brick I carry around.

    Anyone have any suggestions; surely I'm not the only one thinking about this.

All Replies

  • Thursday, October 27, 2005 7:09 PM
    Moderator
     
     
    Hey Vincent. . .

    Yeah, VbSUX did "protect", I would say "almost inhibit",  you from using the API(what a major piece of @#$% was VBSux!!! Not fit for production development!)

    The idea is that most of what you want to do with the API is properly, and rightly, obfuscated via the Object Interface which is the System namespaces of C#. There are a few exceptions. The nice thing is, where there are exceptions, you can easily 'p/invoke' the api calls. This was a pain in the neck using VBSUX.  

    You do have the Platform SDK installed on your machine, right??? Right?????

    You dont?!?

    get it here!

    Lot's of good examples, background info, etc. . . But again, there shouldn't be a need to go to that deep a level. But if there is, you can find many p/invoke declarations at www.pinvoke.net. And if you cant find the exact pinvoke there, at least the ones listed will give you a jumping off point for writing your own.

    Now, I've not read it, but this looks like something you might be interested in.

    Lastly, if you are looking for the best of all worlds -  simple windows API programming, .NET and linux, get your hands on Delphi (stick with versions 8 and below)  . . .  C#, if you didnt know, was created by Anders Hejlsberg, the genius behind Delphi. At the same time, get the JEDI libraries (an open source consortium of delphi programmers have for the most part wrapped up the entire win32s)

    Delphi comes with the source code that makes Delphi, so you can see how the api is used. JEDI also comes with source code!

    Delphi rocks!!! Blows VBSUX out of the water! Why anyone would program in VBSUX by choice or design is beyond me!

    Other books you should have on your shelf (though not api related)
     
    MUST HAVE -> Programming .NET Components
    MUST HAVE -> Advanced .NET Remoting
    And I really like this -> .NET Windows Forms in a Nutshell

    For the most part, I prefer the following publishers (in order of preference)
    O'Reilly
    APress
    Addison-Wesley

    Cheers!
  • Monday, November 07, 2005 12:49 AM
     
     
    This is all you'll ever need:


    Dan Appleman's Visual Basic Programmer's Guide to the Win32 API (Paperback)

  • Sunday, December 04, 2005 11:08 AM
    Moderator
     
     
    if you program vbsux you need the book because vbsux sucks.

    with delphi all you need is delphi.