Analitcs

Pesquisar no conteúdo do blog.atlabs.com.br

quarta-feira, 14 de dezembro de 2016

DELPHI - TStyleManager - Mantendo as cores de painel (ou de controles) quando se utiliza um style (ou skin)

Reações: 
Muito legal o pessoal da Embarcadero lançar a possibilidade de Estilos de tela. Seria melhor ainda manter documentação sobre os itens.

Bem meu problema era:

 Criei um form legal com efeitos de troca de cor quando se passa o mouse sobre alguns paineis, mas quando se aplicava o estilo, tudo ia para os ares.

Com a ajuda do nosso colaborador André Santos, encontramos na internet como retirar (já que o site não explicou por completo, não vou divulgar)


Resumindo, quando você quer retirar um ou mais itens do Estilo do delphi, vá no componente na propriedade "StyleElements"´do componente e retire a opção: seClient

ou vá de função para retirar o estilo de todos os painéis (do form local):




procedure TForm1.FormCreate(Sender: TObject);
var
  I : Integer;
begin
  for I := 0 to Self.ComponentCount -1 do
  begin
    if Self.Components[I] is TCustomControl then
      TCustomPanel(Self.Components[I]).StyleElements := [seFont,seBorder];
  end;
end;

segunda-feira, 12 de dezembro de 2016

DELPHI - Procedure para limpar a cor de um DBLookupComboBox

Reações: 
Fui dar uma ênfase a um componente do tipo "DBLookupComboBox", pintando-o de vermelho.

Até ai beleza, mas ele tinha que ter ficado com as bordas vermelhas e o interior branco quando voltei para a cor normal.

Segue o que resolveu no meu caso.



procedure TForm1.SetColor_DBLookupComboBox(ADBLookupComboBox: TDBLookupComboBox;
  AColor: TColor);
var
  Rect : TRect;
  I : Integer;
begin
  Rect := ADBLookupComboBox.ClientRect;
  for I := 0 to 2 do
  begin
    TComboBox(ADBLookupComboBox).Canvas.FillRect(Rect);
    TComboBox(ADBLookupComboBox).Canvas.Brush.Color := AColor;
    TComboBox(ADBLookupComboBox).Canvas.Pen.Color   := AColor;
    TComboBox(ADBLookupComboBox).Canvas.TextOut(Rect.Left, Rect.Top, ADBLookupComboBox.Text);
    ADBLookupComboBox.repaint;
    ADBLookupComboBox.Color := AColor;
  end;
end;

quinta-feira, 1 de dezembro de 2016

DELPHI - (DELPHI BERLIM 10.2) RAD Studio Berlim Update 2 + O Melhor do Conference 2016

Reações: 












Conheças as melhorias e novas features que chegam junto com o Update 2 do RAD Studio Berlim, e assista as cinco melhores palestras do Embarcadero Conference 2016 na integra para você!

Playlist de videos do youtube

https://www.youtube.com/playlist?list=PLlUDMEtO0HdQYri6QjNbqAjg4LAmv8Yin

quinta-feira, 10 de novembro de 2016

Delphi - Firedac - Processando Comandos em diversos bancos de dados diferentes - Preprocessing Command Text (FireDAC)

Reações: 
Retirado de:

http://docwiki.embarcadero.com/RADStudio/Berlin/en/Preprocessing_Command_Text_(FireDAC)


SQL Dialect Abstraction

If the application needs to support multiple DBMSs, it must be aware that their SQL dialects may be different. FireDAC escape sequences allow you to write SQL dialect-independent SQL commands.
For example, the function to convert string to upper case is different in MySQL, Oracle, and Microsoft SQL Server. But the following command works on any DBMS:
SELECT {ucase(Name)} FROM MyTable
Note that with SQLite, you need to add the FireDAC.Stan.ExprFuncs unit to your "uses" clause. In more complex cases, parts of the command or even the full command must be written differently. Then, the FireDAC conditional escape sequence helps:
{IF Oracle} SELECT * FROM OracleTab {fi}
For example:
{iif (Oracle, TO_CHAR, MSSQL, CONVERT)}          -> ‘TO_CHAR’ ON Oracle ANDCONVERTON SQL Server.
{iif (&v1, Me, &v2, You, We)}                   -> ‘Me’ IF &v1 has nonempty VALUE, ‘you’ IF &v2 has nonempty VALUE, otherwise ‘We’.
{IF Oracle} TO_CHAR {fi} {IF MSSQL} CONVERT {fi} -> TO_CHAR ON Oracle AND CONVERT ON SQL Server.
{IF &v1} Me {fi} {IF &v2} You {fi} -> ‘Me’ IF &v1 has nonempty VALUE + ‘you’ IF &v2 has nonempty VALUE.{
IF MSSQL} SELECT * FROM MSSQLTab {fi}

terça-feira, 8 de novembro de 2016

MSSQL(SQL SERVER) - Procedure Refresh Sequence

Reações: 
CREATE PROCEDURE [dbo].[REFRESH_SEQ_ID]     @NM_SEQ_ID VARCHAR(100),  @TBL varchar(128)  
AS  
BEGIN    
 declare @ParmDefinition NVARCHAR(500);
 declare @VLR integer;
 declare @SQLVLR NVARCHAR(500);
 Set @ParmDefinition = N'@VLROUT Int output';
 Set @SQLVLR = 'SELECT @VLROUT = MAX(*) + 1 FROM ' + @TBL;
   EXEC sp_executesql @SQLVLR, @ParmDefinition, @VLROUT = @VLR OUT;
 declare @SQL varchar(1024) = 'ALTER SEQUENCE ' + cast(@NM_SEQ_ID as varchar(100)) + ' RESTART WITH ' + cast(@VLR as varchar(10)); 
 Begin tran T0; 
   Exec(@SQL);
 Commit tran T0;  
END 
Usando a procedure:
execute REFRESH_SEQ_ID @NM_SEQ_ID = 'SEQ_ID_TABELA', @TBL = 'TBLTABELA';

sexta-feira, 4 de novembro de 2016

DELPHI - Nomes atualizados das Units

Reações: 
As vezes me perguntam: aonde está a unit "jpeg"

Abaixo a solução para suas perguntas



Retirado de:
http://docwiki.embarcadero.com/RADStudio/Seattle/en/Unit_Names_Alphabetical_List_with_Unit_Scopes


Unit Names - Alphabetical List with Unit Scopes


Go Up to Unit Scope Names


This topic contains a reference list of the unit names in RAD Studio along with their associated unit scope names. You can search for a particular unit of interest, and immediately see the unit scope to which the unit belongs.
YellowBang.pngCaution: This list is a snapshot of the XE2 release and will never be updated to reflect subsequent releases.

Alphabetical List of Units with Their Unit Scope Names

ABAccessibility = Vcl.ABAccessibility
AbnfUtils = Xml.Internal.AbnfUtils
AccCtrl = Winapi.AccCtrl
AclAPI = Winapi.AclAPI
ActiveX = Winapi.ActiveX
ActnColorMaps = Vcl.ActnColorMaps
ActnCtrls = Vcl.ActnCtrls
ActnList = Vcl.ActnList
ActnMan = Vcl.ActnMan
ActnMenus = Vcl.ActnMenus
ActnPopup = Vcl.ActnPopup
ADOConst = Data.Win.ADOConst
ADODB = Data.Win.ADODB
ADOInt = Winapi.ADOInt
AdomCore_4_3 = Xml.Internal.AdomCore_4_3
adomxmldom = Xml.adomxmldom
AnsiStrings = System.AnsiStrings
ApacheApp = Web.ApacheApp
ApacheHTTP = Web.ApacheHTTP
ApacheTwoApp = Web.ApacheTwoApp
ApacheTwoHTTP = Web.ApacheTwoHTTP
AppEvnts = Vcl.AppEvnts
AspTlb = Winapi.AspTlb
AutoDisp = Web.AutoDisp
AxCtrls = Vcl.AxCtrls
BandActn = Vcl.BandActn
Bdeconst = Bde.Bdeconst
BindCompDB = Data.Bind.DBScope
BindCompDBLinks = Data.Bind.DBLinks
BindCompEditors = Data.Bind.Editors
BindCompEngExt = Data.Bind.EngExt
BindCompFMXDBEngExt = Fmx.Bind.DBEngExt
BindCompFMXDBLinks = Fmx.Bind.DBLinks
BindCompFMXEditors = Fmx.Bind.Editors
BindCompFMXHandlers = Fmx.Bind.Handlers
BindCompFMXNavigator = Fmx.Bind.Navigator
BindCompFMXResStrs = Fmx.Bind.Consts
BindComponents = Data.Bind.Components
BindCompResStrs = Data.Bind.Consts
BindCompVCLDBEngExt = Vcl.Bind.DBEngExt
BindCompVCLEditors = Vcl.Bind.Editors
BindCompVCLHandlers = Vcl.Bind.Handlers
BindCompVCLResStrs = Vcl.Bind.Consts
BindHelper = System.Bindings.Helper
BindingCustomScope = System.Bindings.CustomScope
BindingCustomWrapper = System.Bindings.CustomWrapper
BindingEngineResStrs = System.Bindings.Consts
BindingExpression = System.Bindings.Expression
BindingExpressionDefaults = System.Bindings.ExpressionDefaults
BindingFactories = System.Bindings.Factories
BindingGraph = System.Bindings.Graph
BindingManager = System.Bindings.Manager
BindingManagerDefaults = System.Bindings.ManagerDefaults
BindingMethods = System.Bindings.Methods
BindingNotifierContracts = System.Bindings.NotifierContracts
BindingNotifierDefaults = System.Bindings.NotifierDefaults
BindingOutputs = System.Bindings.Outputs
BindingSearch = System.Bindings.Search
BrkrConst = Web.BrkrConst
ButtonGroup = Vcl.ButtonGroup
Buttons = Vcl.Buttons
Calendar = Vcl.Samples.Calendar
CaptionedDockTree = Vcl.CaptionedDockTree
CategoryButtons = Vcl.CategoryButtons
CFUtils = System.Mac.CFUtils
CGIApp = Web.CGIApp
CGIHTTP = Web.CGIHTTP
Character = System.Character
CheckLst = Vcl.CheckLst
Classes = System.Classes
Clipbrd = Vcl.Clipbrd
CmAdmCtl = Vcl.CmAdmCtl
CodecUtilsWin32 = Xml.Internal.CodecUtilsWin32
ColorGrd = Vcl.ColorGrd
COMAdmin = Winapi.COMAdmin
ComConst = System.Win.ComConst
ComCtrls = Vcl.ComCtrls
CommCtrl = Winapi.CommCtrl
CommDlg = Winapi.CommDlg
ComObj = System.Win.ComObj
ComObjWrapper = System.Win.ComObjWrapper
ComServ = System.Win.ComServ
ComStrs = Vcl.ComStrs
ComSvcs = Winapi.ComSvcs
Consts = Vcl.Consts
Contnrs = System.Contnrs
Controls = Vcl.Controls
ConvUtils = System.ConvUtils
CopyPrsr = Web.CopyPrsr
Cor = Winapi.Cor
CorError = Winapi.CorError
CorHdr = Winapi.CorHdr
Cpl = Winapi.Cpl
CustomizeDlg = Vcl.CustomizeDlg
D2D1 = Winapi.D2D1
D3DX8 = Winapi.D3DX8
D3DX9 = Winapi.D3DX9
DataBkr = Datasnap.DataBkr
DateUtils = System.DateUtils
DB = Data.DB
DBActns = Vcl.DBActns
DBBdeWeb = Bde.DBBdeWeb
DBByteBuffer = Data.DBByteBuffer
DBCGrids = Vcl.DBCGrids
DBClient = Datasnap.DBClient
DBClientActns = Vcl.DBClientActns
DBCommon = Data.DBCommon
DBCommonTypes = Data.DBCommonTypes
DBConnAdmin = Data.DBConnAdmin
DBConsts = Data.DBConsts
DBCtrls = Vcl.DBCtrls
DBGrids = Vcl.DBGrids
DBLogDlg = Vcl.DBLogDlg
DBLookup = Vcl.DBLookup
DBOleCtl = Vcl.DBOleCtl
DBPlatform = Data.DBPlatform
DBPWDlg = Vcl.DBPWDlg
DBTables = Bde.DBTables
DBWeb = Web.DBWeb
DBXClassRegistry = Data.DBXClassRegistry
DBXClient = Data.DBXClient
DBXClientResStrs = Data.DBXClientResStrs
DBXCommon = Data.DBXCommon
DBXCommonIndy = Data.DBXCommonIndy
DBXCommonResStrs = Data.DBXCommonResStrs
DBXCommonTable = Data.DBXCommonTable
DbxCompressionFilter = Data.DbxCompressionFilter
DBXDataExpressMetaDataProvider = Data.DBXDataExpressMetaDataProvider
DbxDatasnap = Data.DbxDatasnap
DBXDBReaders = Data.DBXDBReaders
DBXDelegate = Data.DBXDelegate
DBXDynalink = Data.DBXDynalink
DBXDynalinkNative = Data.DBXDynalinkNative
DBXEncryption = Data.DBXEncryption
DBXJSON = Data.DBXJSON
DBXJSONCommon = Data.DBXJSONCommon
DBXJSONReflect = Data.DBXJSONReflect
DBXMemoryRow = Data.DBXMemoryRow
DBXMessageHandlerCommon = Data.DBXMessageHandlerCommon
DBXMessageHandlerJSonClient = Data.DBXMessageHandlerJSonClient
DBXMessageHandlerJSonCommon = Data.DBXMessageHandlerJSonCommon
DBXMessageHandlerJSonServer = Data.DBXMessageHandlerJSonServer
DBXMessageHandlerServer = Data.DBXMessageHandlerServer
DBXMetaDataCommand = Data.DBXMetaDataCommand
DBXMetaDataCommandFactory = Data.DBXMetaDataCommandFactory
DBXMetadataCommon = Data.DBXMetadataCommon
DBXMetaDataError = Data.DBXMetaDataError
DBXMetaDataNames = Data.DBXMetaDataNames
DBXMetaDataProvider = Data.DBXMetaDataProvider
DBXMetaDataReader = Data.DBXMetaDataReader
DBXMetaDataUtil = Data.DBXMetaDataUtil
DBXMetaDataWriter = Data.DBXMetaDataWriter
DBXMetaDataWriterFactory = Data.DBXMetaDataWriterFactory
DBXOpenSSL = Data.DBXOpenSSL
DBXOpenSSLRes = Data.DBXOpenSSLRes
DBXPlatform = Data.DBXPlatform
DBXPool = Data.DBXPool
DBXpressWeb = Web.DBXpressWeb
DBXReaderTableStorage = Data.DBXReaderTableStorage
DBXRSAFilter = Data.DBXRSAFilter
DbxSocketChannelNative = Data.DbxSocketChannelNative
DBXSqlScanner = Data.DBXSqlScanner
DBXStream = Data.DBXStream
DBXStreamer = Data.DBXStreamer
DBXStreamPlatform = Data.DBXStreamPlatform
DBXTableFactory = Data.DBXTableFactory
DBXTrace = Data.DBXTrace
DBXTransport = Data.DBXTransport
DBXTransportFilter = Data.DBXTransportFilter
DBXTypedTableStorage = Data.DBXTypedTableStorage
DdeMan = Vcl.DdeMan
DDEml = Winapi.DDEml
DebugUtils = System.DebugUtils
Diagnostics = System.Diagnostics
Dialogs = Vcl.Dialogs
Direct2D = Vcl.Direct2D
Direct3D = Winapi.Direct3D
Direct3D8 = Winapi.Direct3D8
Direct3D9 = Winapi.Direct3D9
DirectDraw = Winapi.DirectDraw
DirectInput = Winapi.DirectInput
DirectMusic = Winapi.DirectMusic
DirectPlay8 = Winapi.DirectPlay8
DirectSetup = Winapi.DirectSetup
DirectShow9 = Winapi.DirectShow9
DirectSound = Winapi.DirectSound
DirOutln = Vcl.Samples.DirOutln
Dlgs = Winapi.Dlgs
DockTabSet = Vcl.DockTabSet
DrTable = Bde.DrTable
DSClientMetadata = Datasnap.DSClientMetadata
DSClientResStrs = Datasnap.DSClientResStrs
DSClientRest = Datasnap.DSClientRest
DSCommonProxy = Datasnap.DSCommonProxy
DSCommonServer = Datasnap.DSCommonServer
DSCommonTable = Datasnap.DSCommonTable
DSConnect = Datasnap.DSConnect
DSHTTP = Datasnap.DSHTTP
DSHTTPCommon = Datasnap.DSHTTPCommon
DSHTTPLayer = Datasnap.DSHTTPLayer
DSHTTPWebBroker = Datasnap.DSHTTPWebBroker
DSIntf = Datasnap.DSIntf
DSLoginDlg = Datasnap.DSLoginDlg
DSNames = Datasnap.DSNames
DSPlatform = Datasnap.DSPlatform
DSProd = Web.DSProd
DSProxy = Datasnap.DSProxy
DSProxyCpp = Datasnap.DSProxyCpp
DSProxyCppRest = Datasnap.DSProxyCppRest
DSProxyDelphi = Datasnap.DSProxyDelphi
DSProxyDelphiRest = Datasnap.DSProxyDelphiRest
DSProxyJavaScript = Datasnap.DSProxyJavaScript
DSProxyRest = Datasnap.DSProxyRest
DSProxyWriter = Datasnap.DSProxyWriter
DSProxyWriterRegistry = Datasnap.DSProxyWriterRegistry
DSReflect = Datasnap.DSReflect
DSServer = Datasnap.DSServer
DSServerResStrs = Datasnap.DSServerResStrs
DSService = Datasnap.DSService
DSTCPServerTransport = Datasnap.DSTCPServerTransport
DSTransport = Datasnap.DSTransport
DSUtil = Data.DSUtil
DTDSchema = Xml.DTDSchema
DwmApi = Winapi.DwmApi
DX7toDX8 = Winapi.DX7toDX8
DxDiag = Winapi.DxDiag
DXErr8 = Winapi.DXErr8
DXErr9 = Winapi.DXErr9
DXFile = Winapi.DXFile
DxgiFormat = Winapi.DxgiFormat
DXTypes = Winapi.DXTypes
EncdDecd = Soap.EncdDecd
EncodingUtils = Xml.Internal.EncodingUtils
EvalProtocol = System.Bindings.EvalProtocol
EvalSys = System.Bindings.EvalSys
Evaluator = System.Bindings.Evaluator
ExcUtils = System.ExcUtils
ExtActns = Vcl.ExtActns
ExtCtrls = Vcl.ExtCtrls
ExtDlgs = Vcl.ExtDlgs
ExtThemes = Vcl.ExtThemes
FileCtrl = Vcl.FileCtrl
FlatSB = Winapi.FlatSB
FMTBcd = Data.FMTBcd
Forms = Vcl.Forms
Gauges = Vcl.Samples.Gauges
GDIPAPI = Winapi.GDIPAPI
GDIPOBJ = Winapi.GDIPOBJ
GDIPUTIL = Winapi.GDIPUTIL
Generics.Collections = System.Generics.Collections
Generics.Defaults = System.Generics.Defaults
GestureConsts = Vcl.Touch.GestureConsts
GestureCtrls = Vcl.Touch.GestureCtrls
GestureMgr = Vcl.Touch.GestureMgr
Gestures = Vcl.Touch.Gestures
GIFConsts = Vcl.Imaging.GIFConsts
GIFImg = Vcl.Imaging.GIFImg
Graphics = Vcl.Graphics
GraphUtil = Vcl.GraphUtil
Grids = Vcl.Grids
HelpIntfs = System.HelpIntfs
HtmlHelpViewer = Vcl.HtmlHelpViewer
HTTPApp = Web.HTTPApp
HTTPD = Web.HTTPD
HTTPD2 = Web.HTTPD2
HTTPProd = Web.HTTPProd
HTTPSOAPTBind = Soap.HTTPSOAPTBind
HTTPUtil = Soap.HTTPUtil
ImageHlp = Winapi.ImageHlp
ImgList = Vcl.ImgList
Imm = Winapi.Imm
IMouse = Vcl.IMouse
IniFiles = System.IniFiles
inquire_v1 = Soap.inquire_v1
IntfInfo = Soap.IntfInfo
InvConst = Soap.InvConst
Invoker = Soap.Invoker
InvokeRegistry = Soap.InvokeRegistry
IOUtils = System.IOUtils
IpExport = Winapi.IpExport
IpHlpApi = Winapi.IpHlpApi
IpRtrMib = Winapi.IpRtrMib
IpTypes = Winapi.IpTypes
Isapi = Winapi.Isapi
Isapi2 = Winapi.Isapi2
ISAPIApp = Web.Win.ISAPIApp
IsapiHTTP = Web.Win.IsapiHTTP
ISAPIThreadPool = Web.Win.ISAPIThreadPool
JConsts = Vcl.Imaging.JConsts
jpeg = Vcl.Imaging.jpeg
Keyboard = Vcl.Touch.Keyboard
KeyboardTypes = Vcl.Touch.KeyboardTypes
KnownFolders = Winapi.KnownFolders
LangUtils = Xml.Internal.LangUtils
LibHelp = Vcl.LibHelp
ListActns = Vcl.ListActns
LZExpand = Winapi.LZExpand
Manipulations = Winapi.Manipulations
Mapi = Winapi.Mapi
Mask = Vcl.Mask
Masks = System.Masks
MaskUtils = System.MaskUtils
Math = System.Math
MConnect = Datasnap.Win.MConnect
Menus = Vcl.Menus
Messages = Winapi.Messages
Midas = Datasnap.Midas
MidasCon = Datasnap.Win.MidasCon
MidConst = Datasnap.MidConst
MMSystem = Winapi.MMSystem
MPlayer = Vcl.MPlayer
MsInkAut = Winapi.MsInkAut
MsInkAut15 = Winapi.MsInkAut15
msxml = Winapi.msxml
Mtsobj = System.Win.Mtsobj
MtsRdm = Datasnap.Win.MtsRdm
Mtx = Winapi.Mtx
MultiMon = Winapi.MultiMon
Nb30 = Winapi.Nb30
ObjAuto = System.ObjAuto
ObjBrkr = Datasnap.Win.ObjBrkr
ObjComAuto = System.Win.ObjComAuto
ObjectArray = Winapi.ObjectArray
ObjEval = System.Bindings.ObjEval
Ole2 = Winapi.Ole2
oleacc = Winapi.oleacc
OleAuto = Vcl.OleAuto
OleConst = Vcl.OleConst
OleCtl = Winapi.OleCtl
OleCtnrs = Vcl.OleCtnrs
OleCtrls = Vcl.OleCtrls
OleDB = Winapi.OleDB
OleDlg = Winapi.OleDlg
OleServer = Vcl.OleServer
OPConvert = Soap.OPConvert
OpConvertOptions = Soap.OpConvertOptions
OpenGL = Winapi.OpenGL
OPToSOAPDomConv = Soap.OPToSOAPDomConv
OPToSOAPDomCustom = Soap.OPToSOAPDomCustom
Outline = Vcl.Outline
ParserUtilsWin32 = Xml.Internal.ParserUtilsWin32
Penwin = Winapi.Penwin
PenWinapi = Winapi.PenWinapi
PlatformDefaultStyleActnCtrls = Vcl.PlatformDefaultStyleActnCtrls
pngextra = Vcl.Imaging.pngextra
pngimage = Vcl.Imaging.pngimage
pnglang = Vcl.Imaging.pnglang
Printers = Vcl.Printers
PropKey = Winapi.PropKey
PropSys = Winapi.PropSys
Provider = Datasnap.Provider
PsAPI = Winapi.PsAPI
Qos = Winapi.Qos
recerror = Vcl.recerror
Registry = System.Win.Registry
RegStr = Winapi.RegStr
RegularExpressions = System.RegularExpressions
RegularExpressionsAPI = System.RegularExpressionsAPI
RegularExpressionsConsts = System.RegularExpressionsConsts
RegularExpressionsCore = System.RegularExpressionsCore
Ribbon = Vcl.Ribbon
RibbonActnCtrls = Vcl.RibbonActnCtrls
RibbonActnMenus = Vcl.RibbonActnMenus
RibbonConsts = Vcl.RibbonConsts
RibbonGalleryBar = Vcl.RibbonGalleryBar
RibbonLunaStyleActnCtrls = Vcl.RibbonLunaStyleActnCtrls
RibbonObsidianStyleActnCtrls = Vcl.RibbonObsidianStyleActnCtrls
RibbonSilverStyleActnCtrls = Vcl.RibbonSilverStyleActnCtrls
RibbonStyleActnCtrls = Vcl.RibbonStyleActnCtrls
RichEdit = Winapi.RichEdit
Rio = Soap.Rio
RTLConsts = System.RTLConsts
RtsCom = Winapi.RtsCom
Rtti = System.Rtti
ScktComp = System.Win.ScktComp
SConnect = Datasnap.Win.SConnect
ScreenTips = Vcl.ScreenTips
ShadowWnd = Vcl.ShadowWnd
Sharemem = System.Sharemem
ShellAnimations = Vcl.ShellAnimations
ShellAPI = Winapi.ShellAPI
ShellConsts = Vcl.Shell.ShellConsts
ShellCtrls = Vcl.Shell.ShellCtrls
SHFolder = Winapi.SHFolder
ShlObj = Winapi.ShlObj
ShLwApi = Winapi.ShLwApi
SimpleShareMem = System.SimpleShareMem
SMINTF = Bde.SMINTF
SOAInv = Soap.SOAInv
SOAPAttach = Soap.SOAPAttach
SOAPAttachIntf = Soap.SOAPAttachIntf
SOAPConn = Soap.SOAPConn
SOAPConst = Soap.SOAPConst
SOAPDm = Soap.SOAPDm
SOAPDomConv = Soap.SOAPDomConv
SOAPEnv = Soap.SOAPEnv
SOAPHTTInv = Soap.SOAPHTTInv
SOAPHTTPClient = Soap.SOAPHTTPClient
SOAPHTTPDisp = Soap.SOAPHTTPDisp
SOAPHTTPTrans = Soap.SOAPHTTPTrans
SOAPLinked = Soap.SOAPLinked
SOAPMidas = Soap.SOAPMidas
Sockets = System.Win.ScktComp
Spin = Vcl.Samples.Spin
SqlConst = Data.SqlConst
SqlExpr = Data.SqlExpr
SqlTimSt = Data.SqlTimSt
StdActnMenus = Vcl.StdActnMenus
StdActns = Vcl.StdActns
StdConvs = System.StdConvs
StdCtrls = Vcl.StdCtrls
StdStyleActnCtrls = Vcl.StdStyleActnCtrls
StdVCL = System.Win.StdVCL
StructuredQuery = Winapi.StructuredQuery
StructuredQueryCondition = Winapi.StructuredQueryCondition
StrUtils = System.StrUtils
SvcMgr = Vcl.SvcMgr
SyncObjs = System.SyncObjs
SysConst = System.SysConst
SysUtils = System.SysUtils
TabNotBk = Vcl.TabNotBk
Tabs = Vcl.Tabs
TConnect = Datasnap.Win.TConnect
ThemedActnCtrls = Vcl.ThemedActnCtrls
ThemeHooks = Vcl.ThemeHooks
Themes = Vcl.Themes
TimeSpan = System.TimeSpan
TlHelp32 = Winapi.TlHelp32
ToolWin = Vcl.ToolWin
TpcShrd = Winapi.TpcShrd
TreeUtils = Xml.Internal.TreeUtils
Types = System.Types
TypeTrans = Soap.TypeTrans
TypInfo = System.TypInfo
UDDIHelper = Soap.UDDIHelper
UITypes = System.UITypes
UriUtils = Xml.Internal.UriUtils
UrlMon = Winapi.UrlMon
UxTheme = Winapi.UxTheme
ValEdit = Vcl.ValEdit
VarCmplx = System.VarCmplx
VarConv = System.VarConv
Variants = System.Variants
VarUtils = System.VarUtils
VCLCom = System.Win.VCLCom
VDBConsts = Vcl.VDBConsts
WebBroker = Web.WebBroker
WebBrokerSOAP = Soap.WebBrokerSOAP
WebCntxt = Web.WebCntxt
WebConst = Web.WebConst
WebFileDispatcher = Web.WebFileDispatcher
WebNode = Soap.WebNode
WebReq = Web.WebReq
WebServExp = Soap.WebServExp
WideStrings = System.WideStrings
WideStringUtils = Xml.Internal.WideStringUtils
WideStrUtils = System.WideStrUtils
Win.CertHelper = Soap.Win.CertHelper
Win.msxmldom = Xml.Win.msxmldom
Wincodec = Winapi.Wincodec
WinCrtl = Winapi.WinCrtl
Windows = Winapi.Windows
WinHelpViewer = Vcl.WinHelpViewer
WinInet = Winapi.WinInet
Winsafer = Winapi.Winsafer
WinSock = Winapi.WinSock
Winsock2 = Winapi.Winsock2
WinSpool = Winapi.WinSpool
WinSvc = Winapi.WinSvc
WMF9 = Winapi.WMF9
WSDLBind = Soap.WSDLBind
WSDLIntf = Soap.WSDLIntf
WSDLItems = Soap.WSDLItems
WSDLLookup = Soap.WSDLLookup
WSDLNode = Soap.WSDLNode
WSDLPub = Soap.WSDLPub
WSDLSOAP = Soap.WSDLSOAP
WSILIntf = Soap.WSILIntf
XDRSchema = Xml.XDRSchema
XMLConst = Xml.XMLConst
XMLDataToSchema = Xml.XMLDataToSchema
XMLDoc = Xml.XMLDoc
xmldom = Xml.xmldom
XMLIniFile = Xml.XMLIniFile
XMLIntf = Xml.XMLIntf
XmlRulesUtils = Xml.Internal.XmlRulesUtils
XMLSchema = Xml.XMLSchema
XMLSchema99 = Xml.XMLSchema99
XMLSchemaTags = Xml.XMLSchemaTags
XPActnCtrls = Vcl.XPActnCtrls
XPMan = Vcl.XPMan
XPStyleActnCtrls = Vcl.XPStyleActnCtrls
XSBuiltIns = Soap.XSBuiltIns
ZLib = System.ZLib
ZLibConst = System.ZLibConst 

quinta-feira, 20 de outubro de 2016

DELPHI - Stream To Byte Array

Reações: 
Retirado do site: https://www.experts-exchange.com/questions/21343717/Copy-a-memory-stream-into-a-byte-array.html
type
  TByteArray  =  Array of Byte;

function StreamToByteArray(Stream: TStream): TByteArray;
begin

  // Check stream
  if Assigned(Stream) then
  begin
     // Reset stream position
     Stream.Position:=0;
     // Allocate size
     SetLength(result, Stream.Size);
     // Read contents of stream
     Stream.Read(result[0], Stream.Size);
  end
  else
     // Clear result
     SetLength(result, 0);

end;

procedure TForm1.Button1Click(Sender: TObject);
var  bytes:      TByteArray;
     strmMem:    TMemoryStream;
     lpBytes:    Array [0..100] of Byte;
     dwIndex:    Integer;
begin

  for dwIndex:=0 to 100 do lpBytes[dwIndex]:=dwIndex;

  strmMem:=TMemoryStream.Create;
  strmMem.Write(lpBytes, SizeOf(lpBytes));

  bytes:=StreamToByteArray(strmMem);

  if CompareMem(bytes, @lpBytes, 100) then
     ShowMessage('Success')
  else
     ShowMessage('Failure');

  strmMem.Free;

end;

terça-feira, 4 de outubro de 2016

DELPHI - Adicionar barra no final de um caminho

Reações: 
Quantas vezes nos deparamos com a adição da barra no final de um caminho de diretórios no windows?

Bem basta utilizar a função: "IncludeTrailingBackslash"
Ex:



var
  Local : String;
begin
  Local := 'C:\windows';
  Local := IncludeTrailingBackslash(Local);
  // A partir deste momento a variável do local ficará: 'C:\windows\', com a barra no final do texto.
end;

segunda-feira, 26 de setembro de 2016

DELPHI - Get System Operational Version (Old GetWinVersion)

Reações: 
Função para recuperar a versão do sistema operacional (Teste realizado com a versão do Delphi 10.1 Berlin)


    Function GetOsVersionDetail: String;
    Function GetOsVersion: String;
//...

function GetOsVersion: String;
var
  AOsVersion : TOsVersion;
begin
  Result := AOsVersion.Name;
end;

function GetOsVersionDetail: String;
var
  AOsVersion : TOsVersion;
  StrL : TStringList;
begin
  StrL := TStringList.Create;
  try
    StrL.Clear;
    StrL.Add(AOsVersion.ToString);
    StrL.Add('--------------------');
    case AOsVersion.Architecture of
      arIntelX86 : StrL.Add('Architecture: IntelX86');
      arIntelX64 : StrL.Add('Architecture: IntelX64');
      arARM32    : StrL.Add('Architecture: ARM32');
      arARM64    : StrL.Add('Architecture: ARM64');
    end;


    case AOsVersion.Platform of
      pfWindows  : StrL.Add('Platform: Windows');
      pfMacOS    : StrL.Add('Platform: MacOS');
      pfiOS      : StrL.Add('Platform: iOS');
      pfAndroid  : StrL.Add('Platform: Android');
      pfWinRT    : StrL.Add('Platform: WinRT');
      pfLinux    : StrL.Add('Platform: Linux');
    end;
    StrL.Add('OS Name: ' + AOsVersion.Name);
    StrL.Add('Buid: ' + Inttostr(AOsVersion.Build));
    StrL.Add('Major Version: ' + Inttostr(AOsVersion.Major));
    StrL.Add('Minor Version: ' + Inttostr(AOsVersion.Minor));
    StrL.Add('ServicePack Major Version: ' + Inttostr(AOsVersion.ServicePackMajor));
    StrL.Add('ServicePack Minor Version: ' + Inttostr(AOsVersion.ServicePackMinor));
  finally
    Result := StrL.Text;
    FreeAndNil(StrL);
  end;
end;

segunda-feira, 19 de setembro de 2016

DELPHI - WebBroker - Como exibir imagens de um diretório local

Reações: 
Como fazer para exibir uma imagem de um site criado pelo webbroker, sem a utilização do Apache ou do ISS por ex?

Simples!

Para isso iremos precisar de uma ação ("action") no WebModule que acione a imagem por linha de comando:


E preparar seu Html para enviar o local da imagem.

Deixei dentro do meu diretório do cgi, um local com as imagens chamado "img"



Criei uma função:


function GetLocalIMG(AImgName: String): String;
begin
  Result := '../Img?Name=' + AImgName;
end;


E no Htm, alterei para exibir o seguinte:

...
    '      ' + sLineBreak +
    '        
' + sLineBreak + ' ' + sLineBreak + ' '...


E no action do Webmodule

procedure TwmLic.wmLicwaImgAction(Sender: TObject; Request: TWebRequest;
  Response: TWebResponse; var Handled: Boolean);
var
  Name: String;
  ImageStream: TmemoryStream;
  sFileImg : String;
  sExt : String;
begin
  Name := Request.QueryFields.Values['Name'];
  Name := StringReplace(Name, '/', '\', [rfReplaceAll, rfIgnoreCase]);

  sFileImg := ExtractFilePath(Application.exeName) + Name;
  if FileExists(sFileImg) then
  begin
    sExt := ExtractFileExt(sFileImg);
    sExt := StringReplace(sExt, '.', '', [rfReplaceAll, rfIgnoreCase]);
    ImageStream := TMemoryStream.Create;
    try
      ImageStream.LoadFromFile(sFileImg);
      ImageStream.Position := 0; // reset ImageStream
      Response.ContentType := 'image/' + sExt;
      Response.ContentStream := ImageStream;
      Response.SendResponse;
    finally
      FreeAndNil(ImageStream);
    end;
  end;
end;


Com este comando acima, você lista a imagem do disco para a memória do servidor, e depois transmite a informação do stream para o html direto.

Testado em Rad Studio 10.1 Berlin em 19/09/2016

terça-feira, 13 de setembro de 2016

DELPHI - ClientDataSet Erro: "missing data provider or data packet" quando é carregado de um stream (LoadFromStream)

Reações: 
Após não achar nada na internet que funcione, fica a dica:

// Salvar um CDS dentro de um campo blob no banco de dados
var
AStreamCDS : TMemoryStream;
AMsgCDS : String;
begin
  //...
  AStreamCDS := TMemoryStream.Create;
  try
    CDS.SaveToStream(AStreamCDS, dfBinary);
    CDSDestino.Edit; // Lembarndo que precisa de um campo de id, caso contrario não funciona no applyupdates
    try
      TBlobField(CDSDestino.FieldByName('CAMPO_BLOB')).LoadFromStream(AStreamCDS);
    except
      on E: Exception do
        AMsgCDS := E.Message;
    end;
    CDSDestino.Post;
  finally
    AStreamCDS.Free;
  end;
  //...



// Salvar de um Campo Blob no banco de dados (um CDS salvo como binario) para um TStream, e recarregar dentro de um CDS
var
AStreamCDS : TStream;
begin
  //...
  AStreamCDS :=  CDS_Local.CreateBlobStream(CDS_Local.FieldByName('BL_DATA_SYNC'), bmRead); // Carrega um Cds salvo dentro de um blob
  try
    ACdsStream := TClientDataSet.Create(Nil);
    ACdsStream.LoadFromStream(AStreamCDS);
  finally
    AStreamCDS.Free;
  end;
  //...

quarta-feira, 24 de agosto de 2016

Delphi - Comando para redução de memória - Command to memory reduction

Reações: 
Retirado de: http://www.agnaldocarmo.com.br/home/comando-milagroso-para-reducao-de-memoria-delphi/
Quando você cria uma aplicação Delphi, tudo é um objeto, o Formulário é um objeto, cada objeto ocupa um espaço da memória gerenciado pelo programa após ser instanciado. E todo objeto após ser utilizado deve ser destruído para que esta memória seja liberada…

O que a maioria dos programadores não sabem é que, especificamente em Delphi que não existe “Coletor de Lixo de memória” como na plataforma .NET. Existe uma memória residual que nunca é liberada mesmo que você destrua todos os objetos que instanciar, porque é uma parta da memória que é administrada pelo próprio Sistema operacional. Se você deixar o seu aplicativo aberto, e efetuar diversas ações que interajam com as APIs do Windows ou DLL externas, trabalhar multi-camadas através de sockets…. Ou mesmo fazer movimentos simples como minimizar ou maximizar sua aplicação… Você perceberá que memória reservada no gerenciador de tarefas para o processo do seu executável crescerá. E muitos destes movimentos como maximiza e minimizar, é a parte não gerenciável da memória de sua aplicação pois ela ocorre na própria interação do Sistema Operacional com sua aplicação.

Este procedimento localiza o processo da aplicação, e limpa toda memória residual…
procedure TrimAppMemorySize;
var
  MainHandle : THandle;
begin
  try
    MainHandle := OpenProcess(PROCESS_ALL_ACCESS, false, GetCurrentProcessID);
    SetProcessWorkingSetSize(MainHandle, $FFFFFFFF, $FFFFFFFF);
    CloseHandle(MainHandle);
  except
  end;
  Application.ProcessMessages;
end;

quinta-feira, 4 de agosto de 2016

DELPHI - Erro: Invalid BLOB ID - ClientDataSet + DataSetPrivider + SQLDataset

Reações: 
Erro: Invalid BLOB ID - ClientDataSet + DataSetPrivider + SQLDataset

Ao restabelecer a conexão com o banco de dados, não sei o porque a propriedade do SQLDataset.MaxBlobSize está sendo alterada de 0 para 1.

Solução:

A - Alterar SQLDataset.MaxBlobSize para 0 toda vez antes de abrir o ClientDataSet

B - Marcar no DataSetProvider da relação a opção "poFetchBlobsOnDemand"

Testes Realizados com DelphiXE8 e não localizada solução na internet

quarta-feira, 3 de agosto de 2016

SQL SERVER - Mostrar as sequences relacionado com determinada tabela

Reações: 
SQL para exibir as Sequences relacionado com uma determinada tabela e seu respectivos campos.


select 
 t.name NOME_TABELA,
 t.object_id ID_TABELA,
 c.name NOME_CAMPO,
 c.default_object_id ID_REFERENCIA,
 d.referenced_major_id ID_SEQUENCIA,
 s.name NOME_SEQUENCIA
from 
 sys.tables t
inner join sys.columns c
 on t.object_id = c.object_id and c.default_object_id <> 0
inner join sys.sql_dependencies d
 on d.object_id = c.default_object_id
inner join sys.sequences s
 on s.object_id = d.referenced_major_id
where t.name = 'TABLE_NAME' -- <--Troque 'TABLE_NAME' pelo nome da sua tabela

terça-feira, 2 de agosto de 2016

WINDOWS - Listar compartilhamentos (Windows Server)

Reações: 
Usar o Windows Management Instrumentation Command-line (WMIC):

Abra um prompt (iniciar>executar) e digite:

WMIC

Agora digite:
SHARE GET CAPTION,NAME,PATH

quarta-feira, 27 de julho de 2016

FIREBIRD - Exibir todas as tabelas e seus campos

Reações: 
Comando para exibir todas as tabelas e seus respectivos campos (Firebird)


SELECT
r.RDB$RELATION_NAME as TABELA,
r.RDB$FIELD_NAME AS CAMPO,
f.RDB$FIELD_TYPE IDTYPE,
CASE f.RDB$FIELD_TYPE
WHEN 261 THEN 'BLOB'
WHEN 14  THEN 'CHAR'
WHEN 40  THEN 'CSTRING'
WHEN 11  THEN 'D_FLOAT'
WHEN 27  THEN 'DOUBLE'
WHEN 10  THEN 'FLOAT'
WHEN 16  THEN 'INT64'
WHEN 8   THEN 'INTEGER'
WHEN 9   THEN 'QUAD'
WHEN 7   THEN 'SMALLINT'
WHEN 12  THEN 'DATE'
WHEN 13  THEN 'TIME'
WHEN 35  THEN 'TIMESTAMP'
WHEN 37  THEN 'VARCHAR'
ELSE          'UNKNOWN'
END AS tipo
FROM RDB$RELATION_FIELDS r
LEFT JOIN RDB$FIELDS f ON r.RDB$FIELD_SOURCE = f.RDB$FIELD_NAME
WHERE (r.RDB$RELATION_NAME not like '%$%') and (r.RDB$RELATION_NAME not like 'VIEW%')

quinta-feira, 7 de julho de 2016

DELPHI - Rolar o TMemo para o inicio ou final de sua tela / Roll the TMemo to the beginning or end of your screen

Reações: 
Retirado do site: http://www.devmedia.com.br/forum/rolar-o-tmemo-para-primeira-linha/311919


procedure ScrollMemo(Memo: TMemo; Direction: Integer);
var
  ScrollMessage: TWMVScroll;
  I: Integer;
begin
  ScrollMessage.Msg := WM_VSCROLL;
  Memo.Lines.BeginUpdate;
  try
    for I := 0 to Memo.Lines.Count do
    begin
     ScrollMessage.ScrollCode := Direction;
     ScrollMessage.Pos := 0;
     Memo.Dispatch(ScrollMessage);
    end;
  finally
    Memo.Lines.EndUpdate;
  end;
end;
 
...
 
ScrollMemo(Memo1, SB_LINEUP); // Rola para o início
ScrollMemo(Memo1, SB_LINEDOWN); // Rola para o final

sexta-feira, 10 de junho de 2016

DELPHI - Versão do Windows - GetWindowVersion

Reações: 
Retirado de: http://stackoverflow.com/questions/8144599/getting-the-windows-version

No XE2 ou superior:

var
  AOSVersion : TOSVersion;
begin
  ShowMessage(AOSVersion.Name);
end;




26 down vote accepted
On XE2 a new class was introduced to deal with this: TOSVersion.
  • Read TOSVersion.Architecture to check for 32 or 64 bit OS.
  • Read TOSVersion.Platform to check for Windows or Mac.
  • Read TOSVersion.Major and TOSVersion.Minor for version numbers.
  • Read TOSVersion.Name to obtain the basic product name, e.g. Windows 7.
  • Read TOSVersion.ToString to obtain the full product name with version, e.g. Windows 7 Service Pack 1 (Version 6.1, Build 7601, 64-bit Edition).

For older versions of Delphi I recommend the following:
In order to check for 2000, XP, Vista, 7 I suggest you read Win32MajorVersion and Win32MinorVersion.
  • major.minor = 5.0 => Windows 2000
  • major.minor = 5.1 => Windows XP
  • major.minor = 5.2 => Windows 2003 server or XP64
  • major.minor = 6.0 => Windows Vista/2008 server
  • major.minor = 6.1 => Windows 7/2008 server R2

segunda-feira, 30 de maio de 2016

Delphi Compiler Version

Reações: 
Compiler CompilerVersion Defined Symbol
Delphi 10.1 Berlin 31 VER310
Delphi 10 Seattle 30 VER300
Delphi XE8 29 VER290
Delphi XE7 28 VER280
Delphi XE6 27 VER270
AppMethod 1 26.5 VER265
Delphi XE5 26 VER260
Delphi XE4 25 VER250
Delphi XE3 24 VER240
Delphi XE2 23 VER230
Delphi XE 22 VER220
Delphi 2010 21 VER210
Delphi 2009 20 VER200
Delphi 2007 .NET 19 VER190
Delphi 2007 18.5 VER185
Delphi 2006 18 VER180
Delphi 2005 17 VER170
Delphi 8 .NET 16 VER160
Delphi 7 15 VER150
Delphi 6 14 VER140
Delphi 5 13(*) VER130
Delphi 4 12(*) VER120
Delphi 3 10(*) VER100
Delphi 2 9(*) VER90
Delphi 1 8(*) VER80
(*) These versions did not have a CompilerVersion constant, it was introduced with Delphi 6.

sexta-feira, 6 de maio de 2016

FIREBIRD - Retirar quebra de linha

Reações: 
-- Exemplo: Lista as triggers do banco em apenas uma linha, sem a quebra
select Replace(Cast(t.rdb$trigger_source as Varchar(512)), ASCII_CHAR(13)||ASCII_CHAR(10), ' ')
   from RDB$DEPENDENCIES d
   inner join RDB$TRIGGERS t on t.RDB$TRIGGER_NAME = d.RDB$DEPENDENT_NAME
   and d.RDB$DEPENDED_ON_NAME like 'GEN%'

FIREBIRD - Como localizar o Generator e seus dependentes

Reações: 
Baseado em:https://www.vivaolinux.com.br/dica/Firebird-Como-localizar-GENERATORS-de-uma-tabela

select d.RDB$DEPENDED_ON_NAME, t.RDB$RELATION_NAME, Replace(Cast(t.rdb$trigger_source as Varchar(512)), ASCII_CHAR(13)||ASCII_CHAR(10), ' ')
   from RDB$DEPENDENCIES d
   inner join RDB$TRIGGERS t on t.RDB$TRIGGER_NAME = d.RDB$DEPENDENT_NAME
   and d.RDB$DEPENDED_ON_NAME like 'GEN%'

FIRBIRD - Localizar os Generators e seus valores

Reações: 
execute block
returns (
    out_name char(31),
    out_value bigint)
as
begin
    for select rdb$generator_name from rdb$generators where rdb$system_flag is distinct from 1 into out_name do
    begin
        execute statement 'select gen_id(' || out_name || ', 0) from rdb$database' into out_value;
        suspend;
    end
end

sexta-feira, 4 de março de 2016

DELPHI - Como Salvar o conteudo de um tblobfield em um TStream

Reações: 
  PRecord : ^RRecord;
  RRecord : Record;
    Teste : String[10];
    IDTeste : Integer;
  end;
// caso contenha um conteudo do tipo record dentro do blob
var
  AStream : Tstream;
  VarRecord : RRecord;
begin
  AStream := Self.ClientDataSet1.CreateBlobStream(TBlobField(Self.CDS.FieldByName('BL_CAMPO_BLOB')), bmRead);
  AStream.Read(VarRecord, SizeOf(VarRecord));
  // resgata o valor do record:
  VarRecord.Teste;
  VarRecord.Idteste;
end;

sexta-feira, 19 de fevereiro de 2016

DELPHI - Pegar posição de TWinControl na tela - GetWinControlPos Function

Reações: 
Function GetWinControlPos(AWinControl : TWinControl) : TPoint;
begin
  Result := AWinControl.ClientToScreen(Point(0,0));
  if Result.X < 0 then
    Result.X := Result.X *-1;
  if Result.Y < 0 then
    Result.Y := Result.Y *-1;

// Retorna posição X e Y do objeto passado por parametro "AWinControl "
end;

terça-feira, 2 de fevereiro de 2016

DELPHI - Programa por linha de comando - Pegando os parametros

Reações: 
// Exemplo de linha de comando:  "C:\Teste.exe" USUARIO=ATLABS -n


function CommandLine(AParam: String): String;
var
  StrCommands : TStringList;
  SAux : String;
  I : Integer;
begin
  Result := '';
  StrCommands := TStringList.Create;
  try
    AParam := AnsiUpperCase(AParam);
    StrCommands.Text := UpperCase(GetCommandLine);
    StrCommands.Text := StringReplace(StrCommands.Text, '"' + Application.ExeName + '"', '', [rfReplaceAll, rfIgnoreCase]);
    SAux := Trim(StrCommands.Text);
    if SAux = '' then
      Exit;
    if Copy(SAux, 1,1) = ' ' then
      Delete(SAux,1,1);
    SAux := StringReplace(SAux, ' ', sLineBreak, [rfReplaceAll, rfIgnoreCase]);
    StrCommands.Text := SAux;
    For i := 0 to StrCommands.Count -1 do
    begin
      if Pos(AParam, StrCommands[I]) > 0 then
      begin
        Result := StrCommands[I];
        Break;
      end;
    end;
  finally
    FreeAndNil(StrCommands);
  end;
end;

// Passado:  CommandLine('USUARIO')            Resultado: 'USUARIO=ATLABS'

Function HasParam(AParam: String): Boolean;
begin
  AParam := AnsiUpperCase(AParam);
  Result := CommandLine(AParam) <> '';
end;

// Passado:  HasParam('-n')            Resultado: True

function GetApplicationParamValue(AParam: String): String;
var
  sCmd : String;
begin
  AParam := AnsiUpperCase(AParam);
  sCmd := CommandLine(AParam);
  Result := Copy(sCmd, Pos('=', sCmd) + 1, length(sCmd)) ;
end;

// Passado:  CommandLine('USUARIO')            Resultado: 'ATLABS'

Max Gehringer