Server Help Forum Index Server Help
Community forums for Subgame, ASSS, and bots
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   StatisticsStatistics   RegisterRegister 
 ProfileProfile   Login to check your private messagesLogin to check your private messages   LoginLogin (SSL) 

Server Help | ASSS Wiki (0) | Shanky.com
Quick Windows API question.

 
Post new topic   Reply to topic Printable version
 View previous topic  Why do people change their names? Post :: Post Very fun new golf game  View next topic  
Author Message
50% Packetloss
Server Help Squatter


Age:40
Gender:Gender:Male
Joined: Sep 09 2003
Posts: 561
Location: Santa Clarita, California
Offline

PostPosted: Tue May 03, 2005 2:42 am   Post maybe stupid    Post subject: Quick Windows API question. Reply to topic Reply with quote

I've been learning some of the basics of the Windows API from http://www.winprog.org/tutorial/ and ran across some stuff I hadn't seen before.
One of which is the GlobalAlloc() function, is this function any different or more efficient than malloc()? Also the CreateFile() function, is this any different or more efficient than fopen(). Both functions can be found under the Reading/Writing Files section of http://www.winprog.org/tutorial/app_two.html

I plan on reading more and placed an order for this book at Borders Books (a book store that works with or is owned by amazon)
Programming Windows, Fifth Edition
I'm not sure if its any good but it will take them 2-6 weeks to even get it in and I am interested if there are any other great books that I should start off with. I don't want to read any MFC crap or .net bullshit. So any help you guys provide is great.

I'm also learning some OpenGL with this book
Beginning OpenGL Game Programming
So far it seems to be a good read. I don't plan on writting any games but maybe some subspace dev software in the very distant future. Any recommended books would be a great help aswell.
Back to top
View users profile Send private message Add User to Ignore List Send email AIM Address
Mr Ekted
Movie Geek


Gender:Gender:Male
Joined: Feb 09 2004
Posts: 1379
Offline

PostPosted: Tue May 03, 2005 3:38 pm   Post maybe stupid    Post subject: Reply to topic Reply with quote

They are both lower level (closer to the operating system). malloc() is a run-time function that ultimately calls HeapAlloc()--similar to GlobalAlloc(). fopen() is a run-time function that ultimately calls CreateFile(). If you want to write machine-independent code, you use the standard malloc/fopen calls which are supported by virtually all forms of C run-time libraries.

GlobalAlloc() doesn't actually return memory. It returns a handle to virtual memory. This means that there are some blocks of virtual memory set aside for you, but that have not been committed for access yet. GlobalLock() takes the handle and forces the memory--if necessary--into real physical RAM, returning the pointer. If you want to use the Windows clipboard functionality, you need to use the Global* family of functions, whose handles can be passed across processes.

CreateFile() can do all sorts of things that fopen() cannot, like pipes, sharing modes, and overlapped I/O.

[edit]

I really should not be saying physical RAM because it's all virtual. Address 0x00400000 for process A is not the same physical pointer as address 0x00400000 for process B.
_________________
4,691 irradiated haggis!


Last edited by Mr Ekted on Tue May 03, 2005 8:30 pm, edited 1 time in total
Back to top
View users profile Send private message Add User to Ignore List
Cyan~Fire
I'll count you!
I'll count you!


Age:37
Gender:Gender:Male
Joined: Jul 14 2003
Posts: 4608
Location: A Dream
Offline

PostPosted: Tue May 03, 2005 4:31 pm   Post maybe stupid    Post subject: Reply to topic Reply with quote

Really, you don't need a book to write Windows code. I started learning from this. (I did have the "hard" copy in help form on my computer, though, which made it a bit easier.)

After you learn the basics and can make a window appear on the screen, check out some open source applications that use the API. For example, if you like AOK, check out my AOKTS source.
_________________
This help is informational only. No representation is made or warranty given as to its content. User assumes all risk of use. Cyan~Fire assumes no responsibility for any loss or delay resulting from such use.
Wise men STILL seek Him.
Back to top
View users profile Send private message Add User to Ignore List Visit posters website
Mr Ekted
Movie Geek


Gender:Gender:Male
Joined: Feb 09 2004
Posts: 1379
Offline

PostPosted: Tue May 03, 2005 4:41 pm   Post maybe stupid    Post subject: Reply to topic Reply with quote

Tsk tsk. Not only returns in the middle of functions, but returns instead of breaks in switch statements! icon_sad.gif
Back to top
View users profile Send private message Add User to Ignore List
50% Packetloss
Server Help Squatter


Age:40
Gender:Gender:Male
Joined: Sep 09 2003
Posts: 561
Location: Santa Clarita, California
Offline

PostPosted: Tue May 03, 2005 8:11 pm   Post maybe stupid    Post subject: Reply to topic Reply with quote

Thanks ekted, do you know of any good books that I should purchase?
_________________
Current Terror Alert Level
Back to top
View users profile Send private message Add User to Ignore List Send email AIM Address
Mr Ekted
Movie Geek


Gender:Gender:Male
Joined: Feb 09 2004
Posts: 1379
Offline

PostPosted: Tue May 03, 2005 8:31 pm   Post maybe stupid    Post subject: Reply to topic Reply with quote

Understanding any aspect of Windows programming is much better with google than any book. You get good API reference, pages with overviews, and some sample code. The reference that comes with Visual Studio is pretty much vertabim from Microsoft's website.
Back to top
View users profile Send private message Add User to Ignore List
Cyan~Fire
I'll count you!
I'll count you!


Age:37
Gender:Gender:Male
Joined: Jul 14 2003
Posts: 4608
Location: A Dream
Offline

PostPosted: Tue May 03, 2005 10:46 pm   Post maybe stupid    Post subject: Reply to topic Reply with quote

Mr Ekted wrote:
Tsk tsk. Not only returns in the middle of functions, but returns instead of breaks in switch statements!

Hey, I started this project a long time ago! It was originally in MFC, you can see how far it has (and I have) come since then... and you can see that I have fixed a few of the DialogProcs, etc. in terms of returns.

And yes, I agree that books are much less efficient than just using the help files and internet for programming. Every programming book I've read did nowhere near as good a job as the better websites on the subject.
Back to top
View users profile Send private message Add User to Ignore List Visit posters website
xrestassuredx
Novice


Age:43
Gender:Gender:Male
Joined: Apr 07 2005
Posts: 48
Location: New York
Offline

PostPosted: Wed May 04, 2005 12:22 am   Post maybe stupid    Post subject: Reply to topic Reply with quote

I occassionally run across a good book that actually does a good job of explaining things with decent examples. If you want to learn MFC, for example, Programming Windows with MFC (2nd Ed.) by Jeff Prosise is one of the best resources I have found, over googling for disparate and often inelegant code examples online.
As far as API programming, I try to stay on as high a level as possible (a software engineer's job description is to be lazy), so I can't help you there. If you are looking for books, though, go to a physical bookstore and look at the books you are buying to see how useful they really will be to you. You can usually find something that will work on google, but not always the "correct" or preferred solution to a problem that you would get from a well-written book.
_________________
Back to top
View users profile Send private message Add User to Ignore List AIM Address
Mr Ekted
Movie Geek


Gender:Gender:Male
Joined: Feb 09 2004
Posts: 1379
Offline

PostPosted: Wed May 04, 2005 2:31 am   Post maybe stupid    Post subject: Reply to topic Reply with quote

xrestassuredx wrote:
I try to stay on as high a level as possible (a software engineer's job description is to be lazy)


Nice flamebait.... icon_smile.gif

Modern software engineers (ie 1995+) have been trained to use wrappers for everything (VB, MFC, STL, etc). Even C++ and Java are basically wrappers. Real design, efficiency, and flexibility of results are 2nd priority to making really quick shitty apps. They have diluted the field to the point where the average developer is now a retard who should be digging ditches.

The wrappers have accomplished their intended goal: more people can now engage in coding. I would compare this to script kiddies. Some real hacker puts in a real effort to make some hacking app. 10,000 people download this tool to "hack". They really have no idea what's going on. They just type commands or click buttons and have some fun. And if it doesn't work exactly right, they have no idea what's wrong. How would you feel if you were on an airplane at 30,000 feet and you found out that some VB flunky wrote part of the plane's hydraulic control system? biggrin.gif
Back to top
View users profile Send private message Add User to Ignore List
Dr Brain
Flip-flopping like a wind surfer


Age:39
Gender:Gender:Male
Joined: Dec 01 2002
Posts: 3502
Location: Hyperspace
Offline

PostPosted: Wed May 04, 2005 9:43 am   Post maybe stupid    Post subject: Reply to topic Reply with quote

That's why CS people don't program embedded systems. That's what computer engineers are for. Programming hydraulic control systems.
_________________
Hyperspace Owner

Smong> so long as 99% deaths feel lame it will always be hyperspace to me
Back to top
View users profile Send private message Add User to Ignore List AIM Address Yahoo Messenger MSN Messenger
SamHughes
Server Help Squatter


Joined: Jun 30 2004
Posts: 251
Location: Greenwich
Offline

PostPosted: Wed May 04, 2005 2:37 pm   Post maybe stupid    Post subject: Reply to topic Reply with quote

Mr Ekted wrote:
[..]

Nice flamebait.... icon_smile.gif

Modern software engineers (ie 1995+) have been trained to use wrappers for everything (VB, MFC, STL, etc). Even C++ and Java are basically wrappers. Real design, efficiency, and flexibility of results are 2nd priority to making really quick shitty apps. They have diluted the field to the point where the average developer is now a retard who should be digging ditches.


I half disagreed with your opinion, but then I realized that I think the same way when it comes to calculators being used in math classes.

I'm thinking of a nice way to torture Mr Ekted: Force him to read the questions asked on a PHP-oriented help forum! Full of priceless things like "How do I do such and such" where "such and such" is something that could be the first example in "Writing FOR loops 101". And some of these people will have customer data in a database!

Or force him to read classics like this one from somebody's CS II assignment:

Code: Show/Hide

{
    long pikachu = 1;
    if (squirtle == 5) {
        /* Blah blah blah... blah blah */

        pikachu = 0;
    }

    if (pikachu == 0) {
        /* Glah glah glah... glah glah */
    }

    pikachu = 0;
}


And all of his variable names would be random irrelevent words that were usually professional "wrestlers" or pokémon or some other riffraff that had nothing to do with the task at hand.
Back to top
View users profile Send private message Add User to Ignore List
Cerium
Server Help Squatter


Age:43
Gender:Gender:Male
Joined: Mar 05 2005
Posts: 807
Location: I will stab you.
Offline

PostPosted: Wed May 04, 2005 2:49 pm   Post maybe stupid    Post subject: Reply to topic Reply with quote

That guy needs to be set on fire...twice.
Once for knowing the names numerous pokemon, and a second time for using them.
Back to top
View users profile Send private message Add User to Ignore List AIM Address
Cyan~Fire
I'll count you!
I'll count you!


Age:37
Gender:Gender:Male
Joined: Jul 14 2003
Posts: 4608
Location: A Dream
Offline

PostPosted: Wed May 04, 2005 5:00 pm   Post maybe stupid    Post subject: Reply to topic Reply with quote

I see nothing wrong with writing your own personal "library" of wrappers that you can use in any application you write. But relying on something like STL and having no clue what's actually going on behind the scenes 1) will make your programming very inefficient and roundabout, and 2) will SUCK for debugging. (Debugging is the primary reason I stopped using STL.)

Naming variables with crappy names is the least of my worries. And of course the friend commented his code up the wazoo, I guess to make sure I understood everything OK.
Back to top
View users profile Send private message Add User to Ignore List Visit posters website
xrestassuredx
Novice


Age:43
Gender:Gender:Male
Joined: Apr 07 2005
Posts: 48
Location: New York
Offline

PostPosted: Thu May 05, 2005 11:06 am   Post maybe stupid    Post subject: Reply to topic Reply with quote

Mr Ekted wrote:
[..]
Modern software engineers (ie 1995+) have been trained to use wrappers for everything (VB, MFC, STL, etc). Even C++ and Java are basically wrappers. Real design, efficiency, and flexibility of results are 2nd priority to making really quick shitty apps.


No.. software engineer != programmer.

I say the job of the software engineer is to be lazy, not to ignore design and slap together something that kind of works, which is akin to saying someone who repairs the suspension bridge with duct tape is a mechanical engineer. What you described is a programmer, probably a CS major with a SE job description..

I'm "lazy" because it's in my best interest to reuse code that's already been written, utilize the standard libraries and to not reinvent the wheel any time I want to do something. That doesn't mean I don't know what's going on behind the scenes, how STL classes are implemented, etc, but I'm not going to program on the API level if it can be helped (and usually, it can).
Back to top
View users profile Send private message Add User to Ignore List AIM Address
Mr Ekted
Movie Geek


Gender:Gender:Male
Joined: Feb 09 2004
Posts: 1379
Offline

PostPosted: Thu May 05, 2005 3:38 pm   Post maybe stupid    Post subject: Reply to topic Reply with quote

Programmer is the entry level position, almost clerical. Here's a spec, do this. A software engineer takes an idea and figures out how it's going to work, how it's going to be put together, where the critical areas are, designs it. I realize this is all just semantics, but be careful what you call yourself depending on who you talk to; it might affect the way they evaluate your skills.
Back to top
View users profile Send private message Add User to Ignore List
Display posts from previous:   
Post new topic   Reply to topic    Server Help Forum Index -> Trash Talk All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum
View online users | View Statistics | View Ignored List


Software by php BB © php BB Group
Server Load: 8 page(s) served in previous 5 minutes.

phpBB Created this page in 0.648430 seconds : 39 queries executed (78.6%): GZIP compression disabled