Thursday, March 12, 2020
DLL and ActiveX Controls From a Delphi Application
DLL and ActiveX Controls From a Delphi Application A popular feature of Delphià is the project deployment of an application with an executable file (exe).à However, if the DLL or ActiveX controls in your project are not registered on the usersââ¬â¢ machines, an ââ¬Å"EOleSysErrorâ⬠will be displayed in response to running the exe file.à To avoid this, use the regsvr32.exe command-line tool. RegSvr32.exe Command Manually using regsvr32.exe (Windows.Start - Run) will register and unregister self-registerable à DLL and ActiveX controls on a system. Regsvr32.exe instructs the system to attempt to load the component and call its DLLSelfRegister function. If this attempt is successful, Regsvr32.exe displays a dialog indicating success. RegSvr32.exe has the following command-line options:à Regsvr32 [/u] [/s] [/n] [/i[:cmdline]] dllname /s - Silent; display no message boxes /u - Unregister server /i - Call DllInstall passing it an optional [cmdline]; when used with /u calls dll uninstall /n - do not call DllRegisterServer; this option mustà à à à à à be used with /ià Call RegSvr32.exe Within Delphi code To call the regsvr32 tool within Delphi code, use the ââ¬Å"RegisterOCXâ⬠function to execute a file and wait for the execution to finish. This is how the RegisterOCX procedure could look: procedure RegisterOCX; type TRegFunc function : HResult; stdcall; var ARegFunc : TRegFunc; aHandle : THandle; ocxPath : string; begin try ocxPath : ExtractFilePath(Application.ExeName) Flash.ocx; aHandle : LoadLibrary(PChar(ocxPath)); if aHandle 0 then begin ARegFunc : GetProcAddress(aHandle,DllRegisterServer); if Assigned(ARegFunc) then begin ExecAndWait(regsvr32,/s ocxPath); end; FreeLibrary(aHandle); end; except ShowMessage(Format(Unable to register %s, [ocxPath])); end; end; Note: the ocxPath variable points to the Flash.ocx Macromedia OCX. To be able to register itself, an OCX must implement the DllRegisterServer function to create registry entries for all the classes inside the control. Do not worry about the DllRegisterServer function, just make sure it is there. For the sake of simplicity, it is presumed that the OCX is located in the same folder as where the application is. The ExecAndWait line in the above code calls the regsvr32 tool by passing the /s switch along with the full path to the OCX. The function is ExecAndWait. uses shellapi; ... function ExecAndWait(const ExecuteFile, ParamString : string): boolean; var SEInfo: TShellExecuteInfo; ExitCode: DWORD; begin FillChar(SEInfo, SizeOf(SEInfo), 0); SEInfo.cbSize : SizeOf(TShellExecuteInfo); with SEInfo do begin fMask : SEE_MASK_NOCLOSEPROCESS; Wnd : Application.Handle; lpFile : PChar(ExecuteFile); lpParameters : PChar(ParamString); nShow : SW_HIDE; end; if ShellExecuteEx(SEInfo) then begin repeat Application.ProcessMessages; GetExitCodeProcess(SEInfo.hProcess, ExitCode); until (ExitCode STILL_ACTIVE) or Application.Terminated; Result:True; end else Result:False; end; The ExecAndWait function uses the ShellExecuteEx API call to execute a file on a system. For more examples of executing any file from Delphi, check out how to execute and run applications and files from Delphi code. Flash.ocx Inside Delphi Exe If there is a need to register an ActiveX control on ââ¬â¹the userââ¬â¢s machine, then make sure the user has the OCX the program requires by placing the entire ActiveX (or DLL) inside the applicationââ¬â¢s exe as a resource. When the OCX is stored inside the exe, it is easy to extract, save to disk, and call the RegisterOCX procedure.
Sunday, March 8, 2020
Chernobyl Disaster essays
Chernobyl Disaster essays The Chernobyl Disaster: Economic, Environmental, and Social Impacts in Europe The nuclear power plant disaster in the town of Chernobyl in 1986 came to have major impact on the environment and the population of the European continent. Due to the lack of security and financial resources, the Chernobyl plant was considered unsafe before the accident; one was able to prevent the accident from happening, as the old Soviet regime would not let any nuclear specialists from the west into the country. As a result, current winds following the disaster brought radioactive particles to Scandinavia and northwestern Europe, which came to have much greater impact than if the winds would have been blowing in another direction. According to De Boer and Catsburg (1997), the Chernobyl accident was not the first incident at a nuclear plant. In 1979, the nuclear plant at Three Mile Island in Pennsylvania had troubles, as well as the nuclear plant at Sellafield in Great Britain 1985. The accident in Chernobyl concerned peoples opinion about safety issues related to nuclear plants (Catsburg, De Boer 254). Much of the information about the Chernobyl disaster has been kept secret from people outside the former republic of Russia, but since the breakdown of the Soviet Union, a lot of information has become available to the west. Nuclear power is a fantastic energy source as it is efficient and leaves minimal chemical pollution, which can be minimized if it is done right. It is extremely effective and consistent, but what if something goes wrong? The oppositional forces to nuclear power received free advertising due to the disaster and the question about nuclear power was once again a subject for discussion. There are about 440 nuclear power reactors and 217 nuclear power plants around the world; so far two have collapsed. This might seem like a small percentage but if one looks at the consequences of the two; one will see devastat...
Subscribe to:
Comments (Atom)