delphi-2010

use shell execute to run cmd as Admin

风流意气都作罢 提交于 2019-12-20 17:29:07
问题 I need to run cmd on a button click as admin. It works. but I need to run it as an admin. How is this done? ShellExecute(Handle, 'open', 'c:\Windows\system32\cmd.exe', nil, nil, SW_SHOWNORMAL) 回答1: Replace the open verb with the runas as shown below. Anyway, try to avoid path hardcoding: uses ShellAPI; procedure TForm1.Button1Click(Sender: TObject); begin ShellExecute(Handle, 'runas', 'cmd.exe', nil, nil, SW_SHOWNORMAL); end; You can also add to your button the shield icon by setting the

Delphi 2010 RTTI : Explore Enumerations

空扰寡人 提交于 2019-12-20 12:08:36
问题 Considering such an enumeration : type TTypeOfData = ( [XmlName('ABC')] todABC, [XmlName('DEF')] todDEF, [XmlName('GHI')] todGHI ); Where XmlName is a custom attribute used to define the serialization string for members of this enumeration. How can I explore the attributes attached to each member of this enumeration ? 回答1: Attributes associated with elements in enumerations are not currently stored in Win32 RTTI data in the executable. RTTI is already responsible for a fair increase in the

Delphi XE2 RTTI broken?

左心房为你撑大大i 提交于 2019-12-20 10:01:12
问题 I recently migrated from D2010 to DXE2 and found a showstopper bug (Or feature?) in XE2 and XE3 (Tested in my friend XE3) related to RTTI generation for TBytes fields inside classes. I found that the RTTI information for a TBytes variable inside a class is never generated. The following code works well in D2010, but shows the message "Error" in XE2/XE3 Does anyone have any clue? This will totally break all our software data serialization implementation To test the code please add Rtti unit to

Delphi XE2 RTTI broken?

本小妞迷上赌 提交于 2019-12-20 10:00:14
问题 I recently migrated from D2010 to DXE2 and found a showstopper bug (Or feature?) in XE2 and XE3 (Tested in my friend XE3) related to RTTI generation for TBytes fields inside classes. I found that the RTTI information for a TBytes variable inside a class is never generated. The following code works well in D2010, but shows the message "Error" in XE2/XE3 Does anyone have any clue? This will totally break all our software data serialization implementation To test the code please add Rtti unit to

How to get a value using SQL in Delphi and setting the value to a variable?

孤街浪徒 提交于 2019-12-20 07:25:27
问题 I'm trying to get the price of medication from the table but i just get: procedure TForm1.BuyButtonClick(Sender: TObject); var iAmount : integer; rRate : real; sMedication : string; sRate : string; begin iAmount := 0; sMedication := BuyCombobox.Items[BuyCombobox.ItemIndex]; dmHospital.qryPrices.SQL.Clear; dmHospital.qryPrices.SQL.Add('SELECT Price(R) FROM MedicationPrices WHERE Medication = quaotedstr(sMedication)'); sRate := dmHospital.qryPrices.SQL; ShowMessage(sRate); end; 回答1: You're not

How to append one array to another array of same type in Delphi?

一个人想着一个人 提交于 2019-12-20 04:57:11
问题 How to append one array to another array of the same type without using iterative statements ( for or while loops) in Delphi? 回答1: Having two dynamic arrays arr1 and arr2 var arr1, arr2: array of Integer; . . . SetLength(arr1, 3); arr1[0] := 1; arr1[1] := 2; arr1[2] := 3; SetLength(arr2, 3); arr2[0] := 4; arr2[1] := 5; arr2[2] := 6; you can append the first to the second like this: SetLength(arr2, Length(arr2) + Length(arr1)); Move(arr1[0], arr2[3], Length(arr1) * SizeOf(Integer)); See System

Creating a UDF for MySQL in Delphi

我的未来我决定 提交于 2019-12-20 02:11:18
问题 How do I create a UDF for MySQL using Delphi? Does anyone have any code templates? I want the code template to be integrated in Delphi versions(2007 and upper), so I need these templates to be usable with and without Unicode support. 回答1: For starters, Google reveals: documentation a forum thread an example You need to create a DLL with a few exported functions, as documented. 来源: https://stackoverflow.com/questions/5894258/creating-a-udf-for-mysql-in-delphi

Getting an IStream from an OleVariant

时光毁灭记忆、已成空白 提交于 2019-12-20 02:10:50
问题 I am using Delphi along with WinHTTP to do an HTTP request to download some files from the internet, and I can do the request but I don't know how to get the IStream from the OleVariant that is returned from ResponseStream . I have spent a lot of time googling but I can't figure out how to do it. Here is what I have tried: var req: IWinHTTPRequest; instream: IStream; begin req := CoWinHTTPRequest.Create; req.Open('GET', 'http://google.com', false); req.Send(''); if req.Status <> 200 then

how to set array length with delphi 2010 rtti

你。 提交于 2019-12-19 23:19:33
问题 how to set array length in runtime ? setLength(t.GetProperty('Propertys'),3); ???? unit Unit3; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TSubProperty = Class private Fitem2: Integer; Fitem1: String; procedure Setitem1(const Value: String); procedure Setitem2(const Value: Integer); published property item1:String read Fitem1 write Setitem1; property item2:Integer read Fitem2 write Setitem2; End; TArraySubPropertys=array of

Delphi 2010: No thread vs threads

不羁的心 提交于 2019-12-19 10:28:14
问题 I'm user of delphi 2010, my current machine is intel core i7, running windows 7 x64. I've write the following codes: type TForm1 = class(TForm) Memo1: TMemo; Button1: TButton; Button2: TButton; procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); private FCount: Integer; FTickCount: Cardinal; procedure DoTest; procedure OnTerminate(Sender: TObject); end; TMyThread = class(TThread) private FMethod: TProc; protected procedure Execute; override; public constructor