How to get S.M.A.R.T. info from disks? - delphi

I tried code found in Google but nothing works and in most cases it doesn't even compile (missing units, undeclared data types etc).
I finally found something that looks complete but shows "The handle is invalid" error:
http://rsdn.org/article/delphi/SMART.xml
You can download the file from here:
http://rsdn.org/article/delphi/smart/smart.zip
The problem is with function function OpenSMART(DrvNum:Byte): THandle;
hSMARTIOCTL:=CreateFile(PChar('\\.\PhysicalDrive'+inttostr(DrvNum)),GENERIC_READ or GENERIC_WRITE,FILE_SHARE_READ or FILE_SHARE_WRITE,nil,OPEN_EXISTING,0,0);
result:= hSMARTIOCTL;
How can I fix it or where can I find working example?
I use Delphi 7 Pro and Delphi 10.3.

OK, it needs to be run as admin. Then it just works.

Related

Invalid Pointer and Access Violation with Native Excel 3 for Delphi

I'm using Delphi 10.2 and the Native Excel 3 library to create spreadsheets.
I have the following code:
var
fWorkbook: IXLSWorkbook;
fSheet1: IXLSWorksheet;
begin
fWorkbook:=TXLSWorkbook.Create;
fSheet1:=fWorkBook.Sheets.Add;
fSheet1.Range['A1','A1'].ColumnWidth:=20;
fSheet1.Range['B1','B1'].ColumnWidth:=20;
fSheet1.Range['C1','C1'].ColumnWidth:=32;
fSheet1.Range['D1','D1'].ColumnWidth:=32;
fSheet1.Range['E1','E1'].ColumnWidth:=14;
fSheet1.Range['F1','F1'].ColumnWidth:=14;
fSheet1.Range['G1','G1'].ColumnWidth:=14;
fSheet1.Range['H1','H1'].ColumnWidth:=14;
fSheet1.Range['I1','I1'].ColumnWidth:=14;
fSheet1.Cells[1,1].Value:='Entry Type';
fSheet1.Cells[1,2].Value:='Intacct Acct #';
fSheet1.Cells[1,3].Value:='Intacct Acct # Description';
fSheet1.Cells[1,4].Value:='Store Name';
fSheet1.Cells[1,5].Value:='Department #';
fSheet1.Cells[1,6].Value:='Location ID';
fSheet1.Cells[1,7].Value:='Project ID';
fSheet1.Cells[1,8].Value:='Grant ID';
fSheet1.Cells[1,9].Value:='Net Amount';
intRow:=fWorkBook.SaveAs(Outfile);
'there is additional code after this.
end;
This code works every time on my development system. I've also used nExcel in other projects without a problem.
However, at the client's system, the fWorkbook.SaveAs generates an "Invalid Pointer" error or Access Violation. Since I cannot duplicate it, debugging is tough.
I have tried moving the SaveAs to various places (after the initial create, after the setting of column widths and where it is now).
Anyone seen this and/or have an explanation?
Thanks!
Malcolm
This problem was resolved by saving the workbook as an xlsx.

Getting Delphi to read a database with a new version of Microsoft Access

We use a Delphi 10 programme that reads in an Access database. I do not deeply understand how it does it, except that I believe it uses units called DAO.pas and DAO_TLB.pas.
I recently upgraded from Office 2007 to Office 2016, and since then the Delphi programme is unable to read from the database; it gives the error:
Project MyProj.exe raised exception class EOleSysError with message 'Class not registered'.
I have tried to search to find how to fix this but am struggling because I don't really understand what's going on under the hood. I tried to install the Access 2016 type library, but that didn't seem to make any difference.
Extremely grateful for any help.
Thanks,
Tom
EDIT: DAO.pas is here. DAO_TLB.pas is where the error is triggered; the function which errors is:
class function CoDBEngine.Create: _DBEngine;
begin
Result := CreateComObject(CLASS_DBEngine) as _DBEngine;
end;
Where CLASS_DBEngine is a constant declared as:
CLASS_DBEngine: TGUID = '{CD7791B9-43FD-42C5-AE42-8DD2811F0419}';
I have also just noticed that, when the error occurs, if I click continue rather than break, a new error appears, saying:
Class not registered, ClassID: {CD7791B9-43FD-42C5-AE42-8DD2811F0419}
i.e. the ClassID is the CLASS_DBEngine constant.

Fast Report fr3 File loading Error in Delphi

I have question about loading *.fr3 in DelphiXE5,
I designed a report and pointed some text to Memo inside of Fast Report everything was ok until I want to load fast Report file from out site App it works for my PC perfectly but when I install client side it gets Error like this Photo include in this message
And the code I used is:
begin
frxReport1.LoadFromFile(ExtractFilePath(Application.ExeName)+'R1.fr3');
frxReport1.PrepareReport();
frxReport1.ShowReport();
end;
Error message:
'18/89765' is not a valid floatin point value
'238/11039' is not a valid floatin point value
'275/90569' is not a valid floatin point value
'41984/5614698264' is not a valid floatin point value
'41984/5618072454' is not a valid floatin point value
'94/48825' is not a valid floatin point value
I found the problem, the problem was Microsoft windows 8.1
I'm using Microsoft Windows 8.1, Delphi Xe 5 and Fast-report 4.15.6
First I made a report in fast report without any change and then run my app in windows 7 save as Fast-report to file and then use in all version of Microsoft Windows, thanks a lot
The problem has been originated form Regional Settings.
Win 8.1 automatically changes decimal separator as '.' to '/' in Persian language, even in fast reports.
The Microsoft has to figure this problem out.
step 1: open frxutils.pas from fastreport lib
step 2: function frxStrToFloat(s: String): Extended;
step 3: relapse this code: [',', '.']) with [',', '.','/']

Error Adding HU_CREATE_GOODSMVT_RFC with delphi TSAPFunction

I'm using TSAPFunction to connect to SAP with Delphi 2009.
Everything works fine, I can use some BAPIU like (RFC_READ_TABLE, BAPI_GOODSMVT_CREATE, etc...).
I'm trying to use HU_CREATE_GOODSMVT_RFC but it doesn't work.
If I try to add functions from OCX I got this error "Could not add functions"
When I try to add it from this code :
FormClientSAP.SAPFunctionsWork.Add('HU_CREATE_GOODSMVT_RFC');
I tried with this code too :
myIFunction:=FormClientSAP.SAPFunctionsWork.Add('HU_CREATE_GOODSMVT_RFC') AS IFunction;
But my function isn't added (FormClientSAP.SAPFunctionsWork.Count = 0).
I try with and without UNICODE components.
I've checked in SAP and this BAPI is RFC enable. And from SE37 I can use it and it works fine.
Can anyone can help me to understand what is wrong?
Thanks for your help.

jcvl not working due to jcl requirements

I am trying to manually install JCL and jvcl for delphi xe2.
I have installed JCL as directed and it seems to have installed with no issues.
Now I try to load the JVCL package 16 , it opens delphi and starts to load libarys, When it gets to the Jedi code Library MPL1.1 i start to get errors like below
Error reading form frmJucolorProviderDesigner
-class tjvcontextprovider not found
Ingnore Cancel Ingnore all
this is not the only one i get quite a few ill post a few more in case it helps
Error reading form JvStandardActions
-tjvSendMailAction not found
-tjvwebaction not found
Error reading form jvCheckItemsEditor
-tjvCheckListBox not found
Error reading form JvControlActoinsDM
-tjvControlcollapseAction not found
-TjvControlexpandAction not found
-TjvControlExportAction not found
-tjvControlOptimizeColumnsAction not found
-TjvControlCustomizeColumnsAction not found
-TjvControlPrintAction not found
Error reading form jvSpeedBarEditorMain
-jvFormStorage not found
-AppRegistryStorage not found
ect... I can add rest if you need.
But each - is its own dialog box with [ignore][cancel][ignore all]
Now after I press Ignore 50 times it will finally load the project, when i try to build all the projects for JVCl package it says required package jcl not found.
in library path i have
..jcl\source\common
..jcl\source\windows
..jcl\source\include
in browsing path i have
..jcl\source\common
..jcl\source\vcl
..jcl\source\windows
and in DCU debug path i have
..jcl\lib\d16\win32\debug
after adding
..jcl\lib\d16\win32, which contains the 32 bit jcl.dcp
The solution is to change the uses to use a fully qualified name:
uses
TypInfo,
{$IFDEF JvInterpreter_OLEAUTO}
OleConst, ActiveX,
{$IFDEF VER230} system.win.ComObj, {$ELSE} ComObj, {$ENDIF}
Now it compiles without error.
Try to add the following to your Search Path(HKCU\Software\Embarcadero\BDS\x.x\Library\Win32), of course including the correct path prefix:
..jcl\source;
..jcl\source\common;
..jcl\source\include;
..jcl\source\vcl;
..jcl\source\windows;
..jvcl\common;
..jvcl\run;
You might also be interested in the following link:
http://andy.jgknet.de/blog/2013/05/how-to-install-jcl-and-jvcl-for-xe4/

Resources