How to mount network disks within Delphi Service? -


I'm a newbie in Delphi, but I have to fix the Delphi code to mount network disks when the service starts " By default, when my application is launched through the Windows service network disk, this is not accessible to the application, so the solution is to include the UNC mapping script in my service. Can this help me with this problem?

Thocks lot.

  unit ALFTSASvcUnit; interface windows, messages, suusutils, classes, graphics, controls, SVCMGR, dialog, shellpi , TLHLP22 uses the strutels; Type TALFTSAService = Class (TService) Process Service Start (Sender: TService; var Start: Boolean); Process ServiceStop (Sender: TService; var Closed: Boolean); Process ServiceExecute (Sender: TService); Personal Private Functions} CountSAAProcs (Procname: string): Integer; Public Function GetServiceController: TServiceController; Override; {Public declaration} end; Var ALFTSAS Service: TALFTSAService; ALLIANCE: string; Arch: string; Implementation {$ R *. DFM} function TALFTSAService.CountSAAProcs (ProcName: string): integer; Vir mahahandal: Thandal; Structure: TProcessEntry32; Start the result: = 0; MyHandle: = CreateToolHelp32 snapshot (TH32CS_SNAPPROCESS, 0); Struct.dwSize: = sizeof (TProcessEntry32); If Process32First (MyHandle, Struct) starts when AnsiStartsText (ProcName, Struct.szExeFile) then inc (result); While Process32 Next (MyHandle, Struct), if AnsiStartsText (ProcName, Struct.szExeFile) then inc (result); End; CloseHandle (MyHandle); // Log message ('BS-number of procedures'' + Initosotr (result), EventLGFFM.A.M.A.Y.Y.Y.E); End; Process Service Controller (CtrlCode: DWord); Stdcall; Start ALFTSAService. Controller (CtrlCode); End; Function TALFTSAService.GetServiceController: TServiceController; Start the result: = service controller; End; Process TALFTSAService.ServiceStart (Sender: TService; var Start: Boolean); Begin ALLIANCE: = 'C: \ Alliance \ Access'; ARCH: = 'win32'; If (ALLIANCE <> '') and (ARCH <> '') then shellExcecute (0, 'Open', PCHAR (Alliance + '\ BSS \ bin \' + ARH + 'Elestant Xa '),' ', zero, SW_SOWNOWNMAL); While (countSaAprax ('BS_') <5) Sleep sleep (10000); While (Counsel Sips ('MxS_') & lt; 8) Sleep Slip (10000); Finally start LogMessage ('SWIFTalliance Environment variable% ALLIANCE%,% ARCH%' unable to receive); Status: = csStopped; End; End; Process TALFTSAService.ServiceStop (Sender: TService; var Closed: Boolean); Start ShellExecute (0, 'Open', PCHAR (Alliance + '\ BSS \ bin \' + ARH + 'Alestop.xe'), '', Zero, SW_SOWNOWNMAL); While (CountessProx ('BS_') gt; 0) Sleep (10000); Sleep (10000); While (Counsel Sips ('Aleppi')> 0) Sleep sleep (5000); Sleep (5000); End; Process TALFTSAService.ServiceExecute (Sender: TService); Const Sebetrinens = 60; Var Count: Integer; Starting Count: 0 =; While not finished, Inc. started (calculated); If calculate; = SecBetweenRuns start counting again: = 0; If (CountSAAProcs ('bs_') & lt; 4) then start the position: = csStopped; break; End; End; Sleep (1000); ServiceThread.ProcessRequests (false); End; End; End. It seems that this is not a Delphi problem, it is believed that what is ShaleXsect which is not working well (I'm not clear). 

In this case, this may be a [Network] file permissions issue, and I suggest you to choose between two different solutions:

  • Read / Write / execute rights for the files required to set logon for the service from the appropriate (and tested) network for the service. Remember services run by the 'System' account by default, which is OK to reach local resources, but not so good for the networked person.
  • To change your shellexact approach, the 'Alestart.exe' is run in the context of a different user (the service is run as a system, the user's credentials to start the 'alestart.exe' process There is a store in its reservoir. Use the CreateProcessWithLogonW API call to initiate a process in the context of a different user. Your process for its operation has been processed on CIMSenNetraSpace Programming will be enabled.

is concerned.


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -