Quantcast
Channel: Planet Object Pascal
Viewing all 1725 articles
Browse latest View live

PARMAJA: FBConfig 2.0.2.14 realesed


Behind the connection: Internet Explorer Automation Part 2

$
0
0
Internet Explorer is a very nice program to automate. There are a large number of actions you can do programmatically from your own application. But when IE is already opened with a bunch of tabs, it is not a trivial task to programmatically select and activate the tab you want. Here after, I will present all the code required to do that. It has been developed using Delphi XE3 but of course as

Behind the connection: Microsoft Word or Excel calls a Delphi application

$
0
0
This tutorial shows how you can have a Microsoft Office (Word, Excel,…) call your Delphi application. For the demonstration, I will use Word. From Word, a macro will call my Delphi application which will prompt the user for some data which will be inserted in the Word document.   In the real world, it is likely that your Delphi application will be a large application managing enterprise

Behind the connection: Original method to iterate the bits within an integer

$
0
0
Today, I would like to present you an original way of iterating thru all the bits in an integer. The usual way of iterating the bits is to build a moving bit mask in a loop and selecting each bit in turn with that mask. This works perfectly and it is fast. But today, I want to show you a better looking way of doing the same iteration. The final code is like this: var   OneBit : Boolean;begin

Firebird News: ActiveRecord Firebird Adapter 0.7.5 for Rails 3.x is released

$
0
0
Here is the gem url https://rubygems.org/gems/activerecord-fb-adapter And here is the full commits changelog : Fix inserting boolean values. Bring gem tasks up to date.  

The Wiert Corner - irregular stream of stuff: jpluimers

$
0
0

This is way cool, and has been there for a long time, and I completely missed it until recently (:

On the Stack Exchange Data Explorer, you can write your own queries for any of the StackExchange sites as they share a common database infrastructure.

The queries can even contain an execution plan, and given the large number of questions (the total of Questions (table Posts) is total over 10 million now: select count(*) as QuestionCount from Posts as Questions).

There are many examples, for instance this one by sam.saffron and  TLama that lists posts outside the Delphi area:

DECLARE @MyUserID INT = ##UserID:int##

SELECT
    Answer.Id AS [Post Link],
    Answer.Score AS [Score],
    Question.Tags,
    Answer.CreationDate AS [Creation Date]
FROM
    Posts Question
LEFT JOIN Posts Answer ON Question.ID = Answer.ParentId
WHERE
    Answer.PostTypeId = 2 AND
    Answer.OwnerUserId = @MyUserID AND
    Question.Tags NOT LIKE '%<delphi>%'
ORDER BY
    Question.CreationDate
ASC

–jeroen

via My answers with non Delphi tag – Stack Exchange Data Explorer.


Filed under: Database Development, Delphi, Development, SQL, SQL Server

Behind the connection: Using Universal Plug And Play (UPnP) with Delphi

$
0
0
UPnP is a set of networking protocols that allows discovery of networked devices supporting UPnP. For example, you can easily discover printers, Wi-Fi access points, internet gateways, Streaming servers and many other types of devices. Microsoft Windows provides an API to use UPnP. This API is located in a DLL which basically exposes a COM interface. You’ll find the documentation on Microsoft

The road to Delphi: Introducing TSMBIOS

$
0
0

logoA few weeks ago I started a new project called TSMBIOS, this is a library which allows access the SMBIOS using the Object Pascal language (Delphi or Free Pascal).

What is the SMBIOS?

SMBIOS stands for System Management BIOS , this standard is tightly related and developed by the DMTF (Desktop Management Task Force).

The SMBIOS contains a description of the system’s hardware components, the information stored in the SMBIOS typically includes system manufacturer, model name, serial numbers, BIOS version, asset tag, processors, ports, device memory installed and so on.

Note : The amount and accuracy of the SMBIOS information depends on the computer manufacturer.

Which are the advantages of use the SMBIOS?

  • You can retrieve the information without having to probe for the actual hardware. this is a good point in terms of speed and safeness.
  • The SMBIOS information is very well documented.
  • You can avoid the use of undocumented functions to get hardware info (for example the RAM type and manufacturer).
  • Useful for create a Hardware ID (machine fingerprint).

How it works?

The BIOS typically populates the SMBIOS structures at system boot time, and is not in control when the OS is running. Therefore, dynamically changing data is rarely represented in SMBIOS tables.

The SMBIOS Entry Point is located somewhere between the addresses 0xF0000 and 0xFFFFF, in early Windows systems (Win95, Win98) it was possible access this space address directly, but after with the introduction of the NT Systems and the new security changes the BIOS was accessible through section \Device\PhysicalMemory, but this last method was disabled as well in Windows Server 2003 Service Pack 1, and replaced with 2 new WinApi functions the EnumSystemFirmwareTables and GetSystemFirmwareTable, Additionally  the WMI supports reading the entire contents of SMBIOS data i using the MSSMBios_RawSMBiosTables class inside of the root\wmi namespace.

Note : you can find more information about the SMBIOS Support in Windows on this link.

The TSMBIOS can be compiled using a WinApi mode (uses the GetSystemFirmwareTable function) or using the WMI Mode (uses the MSSMBios_RawSMBiosTables class)

If you uses the WinApi Mode you  don’t need use COM and the final size of the Application will be smaller, but the WinAPI functions was introduced in Windows Vista and Windows XP x64 (So in Windows Xp x86 will fail). Otherwise using the WMI mode you will need use COM (CoInitialize and CoUninitialize), but also you will get two additional advantages 1) The WMI will work even in Windows Xp x86 systems, 2) You can read then SMBIOS data of local and remote computers.

In order to use the TSMBIOS in your application only you must add the uSMBIOS unit to your uses clause, then create a instance for the TSMBios class using the proper constructor

// Default constructor, used for populate the TSMBIOS class  using the current mode selected (WMI or WinApi)
constructor Create; overload;
// Use this constructor to load the SMBIOS data from a previously saved file.
constructor Create(const FileName : string); overload;
{$IFDEF USEWMI}
// Use this constructor to read the SMBIOS from a remote machine.
constructor Create(const RemoteMachine, UserName, Password : string); overload;
{$ENDIF}

and finally use the property which expose the SMBIOS info which you need. In this case as is show in the sample code the BatteryInformation property is used to get all the info of the batteries installed on the system.

{$APPTYPE CONSOLE}

uses
  Classes,
  SysUtils,
  uSMBIOS in '..\..\Common\uSMBIOS.pas';

procedure GetBatteryInfo;
Var
  SMBios : TSMBios;
  LBatteryInfo  : TBatteryInformation;
begin
  SMBios:=TSMBios.Create;
  try
      WriteLn('Battery Information');
      WriteLn('-------------------');
      if SMBios.HasBatteryInfo then
      for LBatteryInfo in SMBios.BatteryInformation do
      begin
        WriteLn('Location           '+LBatteryInfo.GetLocationStr);
        WriteLn('Manufacturer       '+LBatteryInfo.GetManufacturerStr);
        WriteLn('Manufacturer Date  '+LBatteryInfo.GetManufacturerDateStr);
        WriteLn('Serial Number      '+LBatteryInfo.GetSerialNumberStr);
        WriteLn('Device Name        '+LBatteryInfo.GetDeviceNameStr);
        WriteLn('Device Chemistry   '+LBatteryInfo.GetDeviceChemistry);
        WriteLn(Format('Design Capacity    %d mWatt/hours',[LBatteryInfo.RAWBatteryInfo.DesignCapacity*LBatteryInfo.RAWBatteryInfo.DesignCapacityMultiplier]));
        WriteLn(Format('Design Voltage     %d mVolts',[LBatteryInfo.RAWBatteryInfo.DesignVoltage]));
        WriteLn('SBDS Version Number  '+LBatteryInfo.GetSBDSVersionNumberStr);
        WriteLn(Format('Maximum Error in Battery Data %d%%',[LBatteryInfo.RAWBatteryInfo.MaximumErrorInBatteryData]));
        WriteLn(Format('SBDS Version Number           %.4x',[LBatteryInfo.RAWBatteryInfo.SBDSSerialNumber]));
        WriteLn('SBDS Manufacture Date  '+LBatteryInfo.GetSBDSManufactureDateStr);
        WriteLn('SBDS Device Chemistry  '+LBatteryInfo.GetSBDSDeviceChemistryStr);
        WriteLn(Format('OEM Specific                  %.8x',[LBatteryInfo.RAWBatteryInfo.OEM_Specific]));
        WriteLn;
      end
      else
      Writeln('No Battery Info was found');
  finally
   SMBios.Free;
  end;
end;

begin
 try
    GetBatteryInfo;
 except
    on E:Exception do
        Writeln(E.Classname, ':', E.Message);
 end;
 Writeln('Press Enter to exit');
 Readln;
end.

TSMBIOS Features

  • Source Full documented compatible with the help insight feature, available since Delphi 2005.
  • Supports SMBIOS Version from 2.1 to 2.7.1
  • Supports Delphi 2005, BDS/Turbo 2006 and RAD Studio 2007, 2009, 2010, XE, XE2, XE3.
  • Compatible with FPC 2.6.0 (Windows Only)
  • SMBIOS Data can be obtained using WinApi, WMI or loading a saved SMBIOS dump
  • SMBIOS Data can be saved and load to a file
  • SMBIOS Data can be obtained from remote machines

SMBIOS Tables supported

The TSMBIOS is a Open Source project is hosted in the code google site.



The Wiert Corner - irregular stream of stuff: jpluimers

$
0
0

A couple of notes on NMQ_MQ_LIB and the WebSphere MQ aka MQSeries client libraries:

  • NMQ_MQ_LIB specifies the MQ DLL to use
  • Depending in your interface, the NMQ_MQ_LIB can be an environment variable, application setting, or hardcoded DLL name
  • MQSeries 5.x and WebShpere MQ 6.x require you to specify the bitness in the MQIC DLL name (they don’t accept mqic.dll, but require mqic32.dll) when you access it from the C or Delphi interface.
    MQM DLL does not require bitness: it is mqm.dll in all versions.
  • From client applications, use mqic.dll or mqic32.dll.

And a few links:

I needed this to get some apps talking to MQ on AS/400 aka iSeries aka System i working correctly by getting the DLLs right.

–jeroen


Filed under: .NET, AS/400 / iSeries / System i, Delphi, Development, MQ Message Queueing/Queuing, Software Development, WebSphere MQ

See Different: Planet Object Pascal

$
0
0

I'm glad to announce the creation of Planet Object Pascal.

I have created it in order to provide one place to have all known blog and knowledge of the Object Pascal developers (Virtual Pascal, Free Pascal, Delphi etc…)

If you have a blog that writes about Object Pascal, feel free to contact me, and I'll add you to the planet.

Having said that, I'm looking for a way to better design this, and at the long run, write something a newer system, then continue and using the unmaintained planetplanet system.


Filed under: Object Pascal, אינטרנט, אתרי אינטרנט, טכנולוגיה, פיתוח, קוד פתוח Tagged: object pascal, pascal developers

Firebird News: ANN: AnySQL Maestro 13.2 released

$
0
0
SQL Maestro Group announces the release of AnySQL Maestro 13.2, a powerful tool to manage any database engine accessible via ODBC driver or OLE DB provider (MS Access, SQL Server, Firebird, Oracle, MySQL, PostgreSQL, etc). AnySQL Maestro comes in both Freeware and Professional editions (more information). New version introduces enhanced data management abilities, advanced SQL Dump [...]

Delphi Bistro: Happy Birthday Delphi 18 years and looking great!

$
0
0

On February 14th Delphi will be 18. Looking back it sure came a long way from version 1. I remember when I first walked into a Compusa store and bought my first copy of Delphi. I was beside myself with excitement. Moving from Turbo Pascal to Delphi, moving from DOS to Windows development. That was a very challenging and interesting time indeed.birthday-cake

I am proud of have been a part (as a developer) of that journey. Being a Delphi developer wasn’t always easy. But I am very happy I stuck to my conviction that this is the best tool to develop in and didn’t stray away from it.

Exciting times are ahead, as exciting as picking up my very own copy of Delphi 1. I say that because the future looks very promising and exciting. Cross-platform is here and mobile development are just around the corner.

What better time to be  a Delphi developer? I can proudly answer, now!

So raise your glasses and salute our dev tool! Happy Birthday and many more returns!

And thank you to all the people that made a positive difference in making Delphi what it is today!

 

It's a blong, blong, blong road...: Delphi comes of age

$
0
0

18 years ago today Delphi 1 was launched as a revolutionary way of building native compiled, unmanaged, non-interpreted 16-bit Windows 3 applications using UI-driven RAD principles.

Today Delphi targets Win32, Win64, OS X and at some point soon will also target iOS and Android.

Happy birthday Delphi!

Delphi has come a long way in 18 years, but the basic principles of building Windows applications are just the same today as they were then. The VCL library has expanded and grown considerably, and the IDE has had countless useful features and options added to it over the years.

It’s easy to miss some of the IDE features or forget a useful keystroke. To help you remember some of the more useful ones, please refer to any of these resources:

  • My blog post Delphi IDE productivity keystrokes from July 2012 where I run through some of my favourite IDE keystrokes, mainly in the code editor.
  • My CodeRage 7 session IDE Productivity Tips & Techniques from November 2012 where I demonstrate some of my favourite IDE keystrokes, mainly in the code editor.
  • Cary Jensen’s Delphi Editor (Updated) Key Combination Table. I spent quite some time working with Cary on this (hopefully) comprehensive “cheat sheet” of keystrokes available from the Delphi editor’s default keymapping. It’s a big list and many of the supported functions are accessible through more than one keystroke combination, which makes the list even longer. If you want to find how to do something in the editor with a keystroke shortcut, this is the resource to refer to.
    Note that the online Delphi keystroke documentation is unfortunately deficient and errant in various regards. I made a concerted effort to correct those oversights in this updated shortcut collection.

Keep using Delphi for your native Windows applications and we’ll still be celebrating Delphi’s birthday for many years to come!

The Wiert Corner - irregular stream of stuff: jpluimers

$
0
0

18 years ago, Delphi 1 was launched (still not sure if valentine’s day was a good idea for a product launch).

I wonder – when writing this long before valentine’s day – if the matureness of Delphi finally introduced real undo/redo in the form designer.

Probably still a dream, but still…

–jeroen


Filed under: Delphi, Delphi 1, Development, Software Development

The Wiert Corner - irregular stream of stuff: jpluimers

$
0
0

The current Delphi bindings for WebSphere MQ (formerly known as MQSeries) are very old.

The MA7Q: WebSphere MQ – MQI for Delphi formal binding from IBM is incomplete. Even though it is from 2005, it doesn’t contain the MQCD definition that was there at least since WebSphere MQ 5.2 (released in 2000). And by now it should be gone, since MQSeries 5.x is not supported any more.

A newer one by Dinko Miljak which is mentioned on Delphi 3000 and mentioned on MQSeries.net, has some errors and is from the WebSphere MQ 5.2 era.
It is available via this posting on MQSeries.net (direct download link), and this author reference on Torry.net (direct download link). Both files are identical.

Since it is much more extensive than the IBM version, I am using it to update it for newer WebSphere versions.
Great help while updating are the Gefira MQ bindings for Python: readable, indexed on nullege, and helpful (for instance on the usage of MQHO_UNUSABLE_HOBJ - which is assigned when calling MQCLOSE, I found out later that it is also explained here). The latest Gefira change was in 2008, but still way better than the Delphi bindings.

Also the Perl bindings for MQSeries together with their ASCII/EBCDIC client demo helped a lot.

A big issue when translating is that the i5/OS API in large part uses different names than the regular API.
For instance MQMD (i5/OS) contains MDENCMDCSI and MDFMT fields where MQMD (regular) contains and EncodingCodedCharSetId and Format fields.

As soon as I have done proper translation and upgrading to WebSphere MQ 7.x, I will upload source code.

Source code will be on the BeSharp.net CodePlex repository.

–jeroen


Filed under: Delphi, Development, MQ Message Queueing/Queuing, Software Development, WebSphere MQ

Mariuz's Blog: Adobe Photoshop 1.0 Source Code About 75% is in Pascal

$
0
0
You can read the full article on http://www.computerhistory.org/atchm/adobe-photoshop-source-code/ What i loved was the part about the Efficency and Productivity for Pascal Language , compare that with our days when you need large teams for large and ineficcient java EE projects That first version of Photoshop was written primarily in Pascal for the Apple Macintosh, with some machine

Dr.Bob's Delphi Notes: Happy Birthday Delphi

$
0
0
I cannot imagine what my life would look like without Delphi, or what it would have been if it wasn't for Pascal and Delphi.

DelphiTools.info: Property expressions and statements

$
0
0

Object Pascal does allow binding a property to a field for direct read/writer, but we all have seen properties that required a slightly more complex getter or setter, and that usually meant a method for both. DWScript (svn trunk) & Smart Pascal (1.1) now support property expressions and statements, so the syntax is extended to allow:

property Name : Type read (expression) write (expression|statement)

Under the hood, the compiler will generate an unnamed getter or setter method when appropriate.

Let’s take f.i. a class that exposes an internal list, you can now use just

TMyClass = classprivate
      FList : array of TElement;
   publicproperty Items[i: Integer] : TElement read (FList[i]) 
                                            write (FList[i]); default;
      property Count : Integer read (FList.Length);
end;

Look Ma! No implementation and no constructor needed for trivial properties!
The astute reader will quickly notice how much shorter this is compared to doing it with a TList<T> and classic properties instead.

And for an hypothetical angle value types that accepts both radians and degrees you could have

TMyAngle = recordprivate
      FAngle : Float;
   publicproperty Radians : Float read FAngle write FAngle;
      property Degrees : Float read (RadToDeg(FAngle)) 
                               write (FAngle:=DegToRad(Value));
end;

In the setter statement, there is a special value creatively named… “Value” which holds the value assigned to the property.

In addition to expressions and statements, you can also if specify a property name as getter or setter, this will create an alias (no under-the-hood getter or setter method will be created):

TAncestor = classprivate
      FHidden : Integer;
      procedure SetSecret(v : Integer);
   protectedproperty Hidden : Integer read FHidden write FHidden;
      property Secret : Integer write SetSecret;
end;

TSubClass = class (TAncestor)
   publicproperty Revealed : Integer read Hidden write Secret;
      property OldReveal : Integer read Revealed write Revealed; deprecated;
end;

Which can be of use when you want to make public a protected property under a different name in a subclass, and the underlying field or method being private wasn’t visible. It can also be helpful if you want to rename a property in a migration-friendly way, with the old name deprecated.

So to summarize:

  • read now accepts expressions and properties, in addition to field names and methods names
  • write now accepts writable expressions (the left-side of an assignment), statements (an assignment or a method call) and properties in addition to field names and method names. “Value” contains the value assigned to the property.
  • property expressions are supported for classes, records, helpers and interfaces.

As we weren’t sure of the potential ambiguity, the compiler currently requires the presence of brackets ( ) before the new expressions and statements are allowed, this requirement might be lifted in the future, or maybe not, as it makes such expressions stand out more.
This is an open question, Oxygen accepts read expressions without brackets (but doesn’t have write expressions or statements), so feedback on this aspect is welcome.

Thanks go to Primoz Gabrielcic for providing the unit tests for the above feature!

Behind the connection: Delphi's 18th birthday

$
0
0
Today is Delphi's 18th birthday. Delphi 1 started on February 14, 1995. I started to use it a little bit later and I'm still using it every day. I never regretted that decision. In 1995, Delphi was an extraordinary development tool and it is still today an extraordinary one in its latest incarnation: Delphi XE3. After 64 bits, Windows 8 and MAC OS X Lion, now Delphi goes mobile: http://

Te Waka o Pascal: Hint: Using a Wrong to Make a Wrong Wrong Right

$
0
0
Yesterday I found myself having to write some code that would never be used in order to co-erce the compiler into not complaining that something would not be used when in fact it was. Something I have learned over the years is that hints and warnings are useful guides to code quality. That being the [...]
Viewing all 1725 articles
Browse latest View live