Random Knowledge Dump

| | Comments (2)

1) Declares are case sensitive on all platforms, so if you use them, make you pay attention to case. At the OS level, export tables are case sensitive, which means that the REALbasic linker needs to generate a case sensitive import table in order to work properly. Since REALbasic can't guess what the appropriate case is for a given declare, it's up to the programmer to get it right. Note that this rule may not apply to the library names themselves -- just the declares the library exposes. Case sensitive library names is going to be platform-dependant.

2) If you want to make a backup program on Windows, you can't just use the REALbasic file i/o functionality. If you do, you're going to miss a lot of important information, including file attributes like creation date/time, as well as security information. If you want to do it properly, the appropriate way is to open the file up using the CreateFile API and pass the FILE_FLAG_BACKUP_SEMANTICS for the attributesAndFlags parameter. Take the handle you were given, and use the BackupRead API to read the file's contents into memory. This will capture all of the information needed to completely back the file up. You can use a regular WriteFile (or REALbasic's file i/o) to write the file to the backup location. The reverse operation, restoring a file, is fairly similar. Open the backup file up (you can use REALbasic's file i/o for this), but create the restore file with CreateFile/FILE_FLAG_BACKUP_SEMANTICS. Read the restore file's information into memory, but write it out with BackupWrite.

3) Rebar controls are possible within REALbasic by using declares. The gotcha points aren't appearant though. The control you embed into one of the rebar bands *must* be visible on the window in design mode. You can't drag it off to the pasteboard (for instance). Failing to do that means the control can't be interacted with on the band because REALbasic's framework doesn't know that the control has moved to be on screen. Another gotcha has to do with toolbars -- if you use the built-in toolbar control, then it still does the stupid non-client behavior, which shifts things around in a crazy fashion. Basically, don't use the built-in toolbar on a rebar band because it makes things look like crap (and there's no way to code around it). Handy idea: if you want a menubar to appear as a band in the rebar control, make a window whose frame type is PlainBox and attach that window to the band.

4) Vista has a really nice set of cryptography APIs that are a nice update to the older set of APIs that you used to have to work with. The new set of APIs are more class-centric, and so they're a bit easier to work with. If you ever need powerful hashing, random number generation or other cryptographic features, you should seriously consider looking into declares. The basic idea is that you call BCryptOpenAlgorithmProvider and tell the OS what type of object you want to create (a hash object, for instance). It'll give you back a "token" that represents the requested object. Then you can use APIs like BCryptHashData to do the work on the given token. It's quite easy to work with, and very, very powerful.

That's just a little mini dump of the various things I've been toying with lately. I don't have the energy to turn any of them into a full blog posting lately, but I did want to put the information out there and see if there's any interest in the topics.

2 Comments

What exactly is a 'Rebar' control? Do you have a link to an example or example program that uses it?

Leave a comment

Disclaimer

I'm currently an employee of REAL Software. My blog is mine. The opinions represented in this blog are mine as well and may not represent my employer's opinions. All original material is copyrighted and property of the author.

REALbasic® is a registered trademark of REAL Software, Inc. REAL SQL Server™ and Lingua™ are pending trademarks of REAL Software, Inc. All rights reserved.