loSock = CREATEOBJECT('MSWinsock.Winsock.1') ? loSock.LocalIP loSock = .NULL.
José Temporini
loSock = CREATEOBJECT('MSWinsock.Winsock.1') ? loSock.LocalIP loSock = .NULL.
? Truncar(123.456789,2) -> 123.45 *------------------------------------------- * FUNCTION Truncar(tnNro, tnDec) *------------------------------------------- * Trunca un número en "n" posiciones decimales * USO: Truncar(nNumero, nDecimales) * PARAMETROS: * tnNro = Número a truncar * tnDec = Número de cifras decimales a truncar * RETORNO: Numérico *------------------------------------------- FUNCTION Truncar(tnNro, tnDec) LOCAL ln IF EMPTY(tnDec) tnDec = 0 ENDIF ln = 10 ^ tnDec RETURN ROUND(INT(tnNro * ln) / ln, tnDec) ENDFUNC *-------------------------------------------
*** En el PRG inicial de tu aplicación*** If AppAlreadyRunning() Messagebox('Another instance is already running.') ... Function AppAlreadyRunning Local hsem, lpszSemName #Define ERROR_ALREADY_EXISTS 183 Declare Integer GetLastError In win32API Declare Integer CreateSemaphore In WIN32API ; string @ lpSemaphoreAttributes, ; LONG lInitialCount, ; LONG lMaximumCount, ; string @ lpName lpszSemName = "CadenaUnicadetuAplicacion" hsem = CreateSemaphore(0,0,1,lpszSemName) Return (hsem # 0 And GetLastError() == ERROR_ALREADY_EXISTS)PS:FindWindow() works with ClassNames too.
Local m.myHTML,m.parsed myHTML=[This< br> is an < font color="red">< b>example< /b >< /font >< Hr>x2 < x3] *myHTML= FileToStr(GetFile('HTM')) parsed = '' oParser = Createobject('myParser',m.myHTML,@m.parsed) ? m.Parsed *StrToFile(m.Parsed,'ParseResult.txt') Define Class myParser As Form Add Object oWB As OleControl With ; OleClass = 'Shell.Explorer' Procedure Init Lparameters tcHTML, tcParse lcTemp = Sys(2015)+'.htm' Strtofile(tcHTML,lcTemp) With This.oWB .Navigate2('file://'+Fullpath(lcTemp)) Wait window 'Parsing...' nowait Do While .ReadyState # 4 && Wait for ready state EndDo Endwith Erase (lcTemp) tcParse = This.oWB.Document.body.innerText Wait clear Return .f. Endproc Enddefine
iMsg = CreateObject("CDO.Message") iMsg.From = ALLTRIM(Thisform.txtEmail.Value) iMsg.Subject = ALLTRIM(Thisform.txtAsunto.Value) iMsg.To = ALLTRIM(lcMailAddress) IF !EMPTY(Thisform.txtAdjunto1.Value) iMsg.AddAttachment(ALLTRIM(Thisform.txtAdjunto1.Value)) ENDIF WaitWCtr("Dando formato al mensaje ....",.T.) lcMessage = ALLTRIM(Thisform.txtPlantilla.Value) lcMessage = "file://"+FULLPATH(ALLTRIM(lcMessage)) iMsg.CreateMHTMLBody( lcMessage,0) WaitWCtr("Enviando mensaje....",.T.) iMsg.Send RELEASE iMsg
LOCAL loServer, loBackup loServer = CREATEOBJECT('SQLDMO.SqlServer') loServer.Connect("MiServidor","MiUsuario", "Mi password") loBackup = CREATEOBJECT('SQLDMO.Backup') WITH loBackup .Database = "LabasedeDatos" .Files = '[C:BackupsNombreRespaldo]' .Initialize = .T. .BackupSetName = "MiRespaldo" .BackupSetDescription = "MiDescripcion" .SQLBackup(loServer) ENDWITH
LOCAL lcSQLScript, loConnection loConnection = CREATEOBJECT('ADODB.CONNECTION') loConnection.Open("Provider=SQLOLEDB.1;User ID=MiUsuario"+; +";PWD=MiPassword"+; +";Persist Security Info=False"+; +";Initial Catalog=LaBasedeDatos"+; +";Data Source=MiServidor") lcSQLScript = ; "BACKUP DATABASE [LaBasedeDatos] TO DISK = N'C:BackupsNombreRespaldo' "+; "WITH INIT , NOUNLOAD , NAME = N'MiRespaldo', NOSKIP , STATS = 10, "+; "DESCRIPTION = N'MiDescripcion', NOFORMAT " loConnection.Execute(lcSQLScript)