Place a call using TAPI from Delphi - delphi

I need to initiate a call using TAPI from Delphi 2006. I'd like it to be as simple as possible. Any suggestions for a simple component? Is it in JEDI?

you can use the TurboPower Async Professional, some time ago I used this library and worked perfect, you can find more info about tapi and the AsyncPro component in this link.

Here is a list of components some freeware some shareware
http://www.torry.net/pages.php?id=199
Thanks

To use Tapi and delphi all you need is 2 things.
a. import the dll and create the tlb file.
in the delphi menu, go to componenets, then choose import components, then choose import type library, type "tapi3" and pick the tapi3.dll.
b. with the dll created to make a call you simple need to use
procedure TForm1.Button1Click(Sender: TObject);
var
Request:ITRequest;
dispatch:ITDispatchMapper;
begin
Request := CoRequestMakeCall.create;
Request.MakeCall('555-5555','Tag','client name','Comment');
end;
and replace the '555-5555' with the user input file number, as string.

Add this line before the implementation
function tapiRequestMakeCallW(DestAddress: PWideChar; AppName: PWideChar;
CalledParty: PWideChar; Comment: PWideChar): LongInt; stdcall;
external 'TAPI32.DLL';
after that call tapiRequestMakeCallw like that
TapiSonuc:=tapiRequestMakeCallw(Phone,'', comment, Comment);

Related

Delphi IDE custom menu items, how to Add them?

I am working on a project using Delphi 7 and Delphi 2006, i am developing a component that will get certain system information.
Now the requirement is that after the component is installed on the system, there should be a menu item on the IDE , like this
and for delphi 7 like this
i have searched on the net about adding a menu item but i have not got anything to add an item to the IDE like the one EurekaLog has.
can any body tell me how to add the item like EurekaLog or mysql ?
is it some where in the registry?
To add a menu to the Delphi IDE you must use the Delphi Open Tools API. from here you can access the Main menu of the delphi IDE using a code like this.
LMainMenu:=(BorlandIDEServices as INTAServices).MainMenu;
or
LMainMenu:=(BorlandIDEServices as INTAServices).GetMainMenu;
And then add the menu items which you want.
Check these links for additional samples
Open Tools API Chapter 15: IDE Main Menus
Introduction to the Delphi Open Tools API
How can I add a menu item to the IDE’s main menu?
If you want to specifically add a menu item to the HELP menu, and also make it get removed when your package unloads, and handle enable/disable of the items, then this wizard code might be helpful. I took the sample wizard code that GExperts documentation shows as a starter project, and posted it up here as a slightly nicer start project. You can get started very quickly if you grab this code and just extend it:
https://bitbucket.org/wpostma/helloworldwizard/
What they mean by "Wizard" is a "simple IDE Expert", that is, something with a menu added to the IDE, that implements IOTAWizard and IOTAMenuWizard. This approach has many benefits and is the way that the GExperts wizards are written.
The core of the code is this starter wizard, which needs to be put into a package (DPK) and installed, and registered with the IDE:
// "Hello World!" for the OpenTools API (IDE versions 4 or greater)
// By Erik Berry: http://www.gexperts.org/, eberry#gexperts.org
unit HelloWizardUnit;
interface
uses ToolsAPI;
type
// TNotifierObject has stub implementations for the necessary but
// unused IOTANotifer methods
THelloWizard = class(TNotifierObject, IOTAMenuWizard, IOTAWizard)
public
// IOTAWizard interface methods(required for all wizards/experts)
function GetIDString: string;
function GetName: string;
function GetState: TWizardState;
procedure Execute;
// IOTAMenuWizard (creates a simple menu item on the help menu)
function GetMenuText: string;
end;
implementation
uses Dialogs;
procedure THelloWizard.Execute;
begin
ShowMessage('Hello World!');
end;
function THelloWizard.GetIDString: string;
begin
Result := 'EB.HelloWizard';
end;
function THelloWizard.GetMenuText: string;
begin
Result := '&Hello Wizard';
end;
function THelloWizard.GetName: string;
begin
Result := 'Hello Wizard';
end;
function THelloWizard.GetState: TWizardState;
begin
Result := [wsEnabled];
end;
end.
The registration code is not shown above, but is included in its own "Reg" (registration) unit if you download this from the link above. A tutorial link is on EDN here.

pass adoconnection from vba to delphi

I'm looking to create a COM object in a VBA macro and then pass it to a Delphi DLL (D2009). What should my procedure declaration in Delphi look like?
Background:
I'm expecting (hoping) the VBA macro to:
create the COM object,
invoke the Delphi DLL,
pass the COM object to the Delphi DLL procedure,
stay alive until the Delphi DLL closes itself (the DLL will have embedded forms for the user to interact with).
I think I'll need to create a callback function to let the VBA macro know that I'm done so it can tidy up but I'll work on that independently of this question.
UPDATE
More specifically: What should the exported function declaration be for the Delphi DLL.
you have to pass ADO Connection interface link _Connection to delphi procedure
then create TADOConnection instance and replace ConnectionObject with new interface link
library Project1;
uses ADODB;
{$R *.res}
procedure SetConnection(aDBConnection : _Connection); stdcall;
var connect : TADOConnection;
begin
connect := TADOConnection.Create(nil);
try
connect.ConnectionObject := aDBConnection;
//here you can use your connection
finally
connect.Free();
end;
end;
exports SetConnection name 'SetDBConnection';
begin
end.
it is better to use stdcall calling convention. using export keyword setConnection proc is available from uotside with SetDBConnection name , so you can LoadLibrary and getProcAddress to find its entry point (really I don't know VBA so I can't say how to load library using it)

Inno setup / pascal scripting - is there any way to use Aero (dwmapi)?

I would like to build a custom setup, with an aero form, but I don't know how to start it.
Is there any way to use DWM API with inno setup?
function dwm(Wnd: HWnd; cxLeftWidth, cxRightWidth, cyTopHeight, cyBottomHeight: integer ): Longint; external 'DwmExtendFrameIntoClientArea#dwmapi.dll stdcall';
DWM API is a native API so you can access it using the DLL Import method.
Then you can call API functions in your script code.
But I would recommend against doing this. Since the DWM only works on Vista or later and it can be disabled by stopping the NT Service. It could prevent your installation from working on a machine that it was designed to work on.
Now that you posted your code...
Original declaration of the API you posted.
HRESULT WINAPI DwmExtendFrameIntoClientArea(
HWND hWnd,
__in const MARGINS *pMarInset
);
My best guess is that it should look like this instead.
type
Margins = record
cxLeftWidth : Integer;
cxRightWidth: Integer;
cyTopHeight: Integer;
cyBottomHeight: Integer;
end;
function DwmExtendFrameIntoClientArea(Wnd: HWnd;
var pMarInset : MARGINS) :
HRESULT;
external 'DwmExtendFrameIntoClientArea#dwmapi.dll cdecl';
you can use the third party tool ISSkin for inno setup
http://isskin.codejock.com/
hope this helps
I would not use such an approach in a setup program, but if you you really need it I would develop it in Delphi, wrap it in a DLL with a simpler API, and call that DLL from InnoSetup.

Delphi Win32 Receiving a datatable from ASP.NET service

I'm building a Delphi Win32 app that should consume a Soap Service, which turns out to be a .NET based app. One function returns a DataTable. Of course, Delphi Win32 (not Delphi .NET) has no way of understanding this natively.
Any way I can make it work? I'll be happy to parse the XML manually too, but I've no idea how to get hold of the raw XML response.
The WSDL: https://stratus.voxamvia.co.za/api.asmx?WSDL
The function: GetNotifications which returns GetNotificationsResult, which builds as:
GetNotificationsResult = class(TRemotable)
private
Fnamespace: WideString;
Fnamespace_Specified: boolean;
FtableTypeName: WideString;
FtableTypeName_Specified: boolean;
procedure Setnamespace(Index: Integer; const AWideString: WideString);
function namespace_Specified(Index: Integer): boolean;
procedure SettableTypeName(Index: Integer; const AWideString: WideString);
function tableTypeName_Specified(Index: Integer): boolean;
published
property namespace: WideString Index (IS_ATTR or IS_OPTN) read Fnamespace write Setnamespace stored namespace_Specified;
property tableTypeName: WideString Index (IS_ATTR or IS_OPTN) read FtableTypeName write SettableTypeName stored tableTypeName_Specified;
end;
Any help appreciated!
Would it help if I implement RemObjects?
You can build your dataset from xml. This should give you a starting point: http://www.gekko-software.nl/DotNet/Art07.htm and http://www.gekko-software.nl/DotNet/Art08.htm.
I haven't used DataAbstract from RemObjects, so I can not give an advice on it.
LE: you can access and consume a web service written in .net by following this simple article well written by drbob - Consuming C# Web Services with Delphi 7 Professional
which contains also a small example on how to build dynamically and how to use the THttpRio (is the same as the Mikael Eriksson's answer)
Any way I can make it work? I'll be happy to parse the XML manually
too, but I've no idea how to get hold of the raw XML response.
You can get it in the OnAfterExecuteEvent on your THTTPRIO component. There you will have SOAPResponse: TStream as a parameter.
Update:
To get the event to fire you add a THTTPRIO component, create the event handler and use the RIO component as the third parameter to GetAPISoap.
This worked for me. HTTPRIO1 is a component on the form.
procedure TForm7.Button1Click(Sender: TObject);
var
A: APISoap;
begin
A := GetAPISoap(False, '', HTTPRIO1);
A.Validate_User('', '');
end;

What is the most common way to create a folder selection dialog using Delphi?

There doesn't appear to be a simple component available to create a folder selection dialog in Delphi 2009, although a file selection dialog is provided by way of the TOpenDialog.
What is the most common way to create a modern folder selection dialog using Delphi?
There are two overloaded routines in FileCtrl.pas called SelectDirectory
For a modern look, use the second form, with sdNewUI
var
dir : string;
begin
dir := 'C:\temp';
FileCtrl.SelectDirectory('Select', 'C:\', dir, [sdNewFolder, sdNewUI], Self);
end;
NOTE: sdNewFolder, sdNewUI etc are only available from D2006+
you can use SelectDirectory from FileCtrl unit
using FileCtrl;
var
St: string;
begin
St:='c:\';
if SelectDirectory(St,[],0) then
begin
end;
end;
You can download a component PBFolderDialog from "http://bak-o-soft.dk/Delphi/PBFolderDialog.aspx" which is quite easy to use and offers access to all options of the Windows "SHBrowseForFolder" dialog; something which the built-in ones not do.
It's freeware with source and not too difficult to port to Delphi 2009.
See the sample code:
Delphi tip#157: select folder dialog
http://www.scalabium.com/faq/dct0157.htm

Resources