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

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.

Related

How popup "Connect To" dialog?

how to popup this form use delphi ?
is ShellExecuteEx or ShellExecute can do this?
From the command line you can do this. (at least, on Win7 for me...()
rundll32.exe van.dll,RunVAN
So, just wrap that in a suitable ShellExecute or similar call.
Note that the dialog is designed to pop up in the system tray. I don't know how you'd get it to appear somewhere more obvious.
Also, have a look at this thread. There's another way mentioned here that describes how to do it in a possibly more useful fashion:
https://groups.google.com/forum/?hl=en&fromgroups=#!topic/microsoft.public.development.device.drivers/nPn-PH3g_2Q
If you want to invoke this from your program, it's simpler just to skip the rundll32 call. You can load the DLL yourself and invoke the function. For example:
procedure RunVANW(hwnd: HWND; hinst: HINST; lpszCmdLine: LPSTR;
nCmdShow: Integer); stdcall; external 'van.dll';
procedure ShowViewAvailableNetworksDialog;
begin
RunVANW(0, 0, nil, 0);
end;
I would expect that this functionality is not available on older versions of Windows, and almost certainly will be modified on future versions of Windows. So you may prefer to write the DLL import using LoadLibrary and GetProcAddress, and switch behaviour at runtime depending on whether or not the RunVANW function is available.

Delphi 7 DLL to be called from Delphi XE

I need to wrap some legacy code in Delphi 7 for use within Delphi XE2. My question seems simple, but I tried ALL the examples I could find and they all fail. Basically, I need to be able to pass strings between D7 and DXE2, and as far as I can figure out, the safest approach is to use pchar (since I do not want to ship the borlandmm dll).
So DLL written in D7, to be called by Delphi XE2
My interface needs to be
IN My DLL:
function d7zipFile(pFatFile,pThinFile : PChar) : integer; stdCall;
function d7unzipfile(pThinFile,pFatFile : PChar) : integer; stdCall;
I need to pass BACK the pFatFile name in the unzipfile function.
In My calling code:
function d7zipFile(pFatFile,pThinFile : PChar) : integer; external 'd7b64zip.dll';
function d7unzipfile(pThinFile,pFatFile : PChar) : integer; external 'd7b64zip.dll';
Could someone please assist with the best way to implement these?
Obviously I am not looking for the actual zip/unzip code - I have that working fine within D7. I want to know how to declare and work with the string / pchar params, since the various types I tried (PWideChar, WideString, ShortString etc) all give errors.
So I would be happy to simply be able to do a showMessage in the d7zipFile function for both filenames.
And then be able to do a showMessage in delphiXE2 on the pFatFile variable, which means the strings went both ways OK?
By far the easiest way to do this is to use WideString. This is the Delphi wrapper around the COM BSTR type. Dynamic allocation of the string payload is done using the shared COM allocator. Since the Delphi RTL manages that, it is transparent to you.
In the Delphi 7 code you declare your functions like this:
function d7zipFile(const FatFile, ThinFile: WideString): integer; stdcall;
function d7unzipfile(const ThinFile: WideString; var FatFile: WideString):
integer; stdcall;
In your calling code you declare the functions like this:
function d7zipFile(const FatFile, ThinFile: WideString): integer; stdcall;
external 'd7b64zip.dll';
function d7unzipfile(const ThinFile: WideString; var FatFile: WideString):
integer; stdcall; external 'd7b64zip.dll';
The alternative to this approach is to use PAnsiChar or PWideChar. Note that you cannot use PChar because that alias refers to different types depending on which version of Delphi you use. In Delphi 7 PChar is an alias for PAnsiChar, and in XE2 it is an alias for PWideChar.
The big downside of using PAnsiChar, say, is that the caller needs to allocate the string which is returned from the DLL. But typically the caller does not know how large that string needs to be. There are a variety of solutions to the problem but the neatest approach is always to use a shared allocator. You state that you do not want to rely on borlandmm.dll and so the next most obvious common allocator is the COM allocator. And that's why WideString is attractive.

Calling an API Function from DINPUT.Dll Using Delphi Or Pascal

I have a program which uses an API from dinput.dll (Direct Input), I have monitored it and the result is this:
API Name: DirectInputCreateEx
Module Name: C:\Windows\system32\DINPUT.dll
And about another program which uses Direct Input:
API Name: DirectInputCreateA
Module Name: C:\Windows\system32\DINPUT.dll
This API will update this registry key:
HKEY_CURRENT_USER\System\CurrentControlSet\Control\MediaProperties\PrivateProperties\DirectInput
I want to know How can I use Delphi to write a code which ONLY call this API for DirectInput dll?
Any Help is really appreciated...
In order to call Direct Input you will need a Delphi translation of the header file. The best such translation, to my knowledge, is available from the Clootie graphics pages.
You need to use the DirectInput.pas header translation.
As for writing a program that does not show a Window, here's the simplest template:
program MyProgram;
begin
//write your program's code here
end.
You state in a comment that the only function you wish to call is DirectInputCreateEx. To call that function you need the following import declaration:
function DirectInputCreateEx(hinst: THandle; dwVersion: DWORD;
const riidltf: TGUID; out ppvOut; punkOuter: IUnknown): HResult;
stdcall; external 'dinput.dll';

How to fix a delayed declaration in UxTheme

In Delphi XE UxTheme unit there is the following declaration
function DrawThemeTextEx(hTheme: HTHEME; hdc: HDC; iPartId: Integer; iStateId: Integer;
pszText: LPCWSTR; cchText: Integer; dwTextFlags: DWORD; pRect: PRect;
var pOptions: TDTTOpts): HResult; stdcall;
external themelib name 'DrawThemeTextEx' delayed;
My Windows XP Professional with SP3 does not have such function in the uxtheme.dll (checked with dllexp.exe from http://www.nirsoft.net/utils/dll_export_viewer.html)
It seems like my application does delayed loading of the procedure and fails runtime with the following error:
Project mtgstudio.exe raised exception class EExternalException
with message 'External exception C0FB007F'.
The issue was encountered in JVCL as well but resolved there as per http://andy.jgknet.de/blog/2009/09/once-upon-a-delayed-jvcl-time/
I need UxTheme fixed because they are used by the DevExpress components as well.
Is there a way to patch/fix the UxTheme.pas DrawThemeTextEx declaration to be non-delayed?
The fundamental problem is that this API was introduced in Vista and is not available in XP.
The whole point of the delayed keyword is to allow functions like this to be made available easily to developers who want to take advantage of newer API functions. But to do so the developer typically must also provide fallback implementations for older OS versions, which DevExpress appear to have failed to do.
The bug is therefore not in UxTheme.pas, but in the DevExpress component that calls an API that is not implemented on the platform. The fix is to re-work the DevExpress code to avoid calling this API on XP.
I suggest you contact DevExpress who quite probably already have a fix in their latest versions.

Place a call using TAPI from 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);

Resources