From RAD Studio Code Examples
Jump to: navigation, search


This storage class specifier helps publish the server methods in DataSnap applications.

Server Code

Header file containing the server class:

#ifndef Unit1H
#define Unit1H

class __declspec(delphirtti) myclass : public TPersistent {
	double sum(double const a, double b);

Implementation of the server class:

#pragma hdrstop

#include "Unit1.h"

myclass::myclass() {

double myclass::sum(double const a, double b) {
	return a + b;

Client Code

Header file:

class TForm4 : public TForm {
__published: // IDE-managed Components

	TLabel *Label1;
	TLabel *Label2;
	TEdit *Edit1;
	TButton *Button1;
	TEdit *Edit2;
	TSQLConnection *SQLConnection1;
	TEdit *Edit3;
	TLabel *Label3;

	void __fastcall Button1Click(TObject *Sender);

private: // User declarations
		public : // User declarations
	__fastcall TForm4(TComponent* Owner);

Implementation file:

#include <vcl.h>
#pragma hdrstop

#include "Unit4.h"
#include "Unit7.h"
// ---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"

TForm4 *Form4;

// ---------------------------------------------------------------------------
__fastcall TForm4::TForm4(TComponent* Owner) : TForm(Owner) {

// ---------------------------------------------------------------------------
void __fastcall TForm4::Button1Click(TObject *Sender) {
	myclassClient* tmp = new myclassClient(SQLConnection1->DBXConnection);
	double a, b;

	try {
		a = StrToFloat(Edit1->Text);
		b = StrToFloat(Edit2->Text);
		Edit3->Text = FloatToStr(tmp->sum(a, b));

	__finally {

See Also