© J.C. Kessels 2009
MyDefrag Forum
May 20, 2013, 03:53:27 pm
Welcome,
Guest
. Please
login
or
register
.
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
News
:
Home
Help
Search
Login
Register
MyDefrag Forum
>
JkDefrag v3 Forum
>
Programming with the library
>
Error Use Library In Delphi.
Pages:
1
2
3
[
4
]
« previous
next »
Print
Author
Topic: Error Use Library In Delphi. (Read 40928 times)
puma
Newbie
Posts: 4
Re: Error Use Library In Delphi.
«
Reply #45 on:
June 11, 2008, 07:02:08 am »
Yes while Im compiling I get the error I just............ The above error occured on following pascal that you provided in your library. Please guide me.....thankyou
program Defrag;
{$APPTYPE CONSOLE}
Uses sysutils;
///////////////This is the Defragmentor function
procedure RunJkDefrag(
Path: PWideChar;
Mode: Integer;
Speed: Integer;
FreeSpace: Double;
Excludes: array of PWideChar;
SpaceHogs: array of PWideChar;
Running: PInteger;
RedrawScreen: PInteger;
ShowStatus, ShowMove, ShowAnalyze, ShowDebug, DrawCluster, ClearScreen: Pointer;
DebugMsg: array of PWideChar);
stdcall; external 'JkDefragLib' name 'RunJkDefrag';
procedure StopJkDefrag(Running: Pointer; TimeOut: Integer);
stdcall; external 'JkDefragLib' name 'StopJkDefrag';
procedure ShowStatus(Data: pointer); CDECL;
begin
writeln('Show the Status:');
end;
procedure ShowMove(Item: pointer; Clusters, FromLcn, ToLcn, FromVcn: int64); CDECL;
begin
writeln('Show the movement Move:');
end;
procedure ShowAnalyze(Data: pointer; Item: pointer); CDECL;
begin
writeln('Show the analyser Analyze:');
end;
procedure ShowDebug(Level: Integer; Item: Pointer; Format: PChar; Args: Array of const); CDECL;
begin
writeln('The Debug Information: ',Format);
end;
procedure DrawCluster(Data: pointer; ClusterStart, ClusterEnd: int64; Color: Integer); CDECL;
begin
writeln('Draw the Cluster Information:');
end;
procedure ClearScreen(Format: PChar; Args: Array of const); CDECL;
begin
writeln('ClearScreen: ',Format);
end;
var
Excludes : Array of PWideChar = nil;
SpaceHogs : Array[0..2] of PWideChar = (
'?:\WINDOWS\ServicePackFiles\*',
'*.zip',
nil
);
Running: Integer;
RedrawScreen: Integer;
VolumeName :PwideChar;
DriveId:Integer;
//Running,RedrawScreen:PInteger;
DefaultDebugMsg:Array of PWideChar = nil;
begin
DriveId:=5;
New(VolumeName);
VolumeName:= 'F:';
writeln('Starting Ultra Amco ');
// DrawCluster(Data: pointer; ClusterStart, ClusterEnd: int64; Color: Integer);
//RunJkDefrag.....................0,0,1
//Volume name C
//Excluded......
Excludes:=nil;
RunJkDefrag(VolumeName,40,40,1,Excludes,
SpaceHogs,@Running,@RedrawScreen,
@ShowStatus,
@ShowMove,@ShowAnalyze,@ShowDebug,
@DrawCluster,
@ClearScreen,
DefaultDebugMsg);
//Volume is free
//
Dispose(VolumeName);
ReadLn;
end.
Logged
jeroen
Administrator
JkDefrag Hero
Posts: 7155
Re: Error Use Library In Delphi.
«
Reply #46 on:
June 12, 2008, 03:36:18 am »
I see several differences between your code and the original JkDefrag example. In your code the RunJkDefrag and StopJkDefrag are declared as "stdcall", but in the original as CDECL. And you have defined the "Excludes" as "nil", not as an array of PWideChar.
Logged
puma
Newbie
Posts: 4
Re: Error Use Library In Delphi.
«
Reply #47 on:
June 12, 2008, 04:43:15 am »
I tried the one provided in example but the story is same, Im facing the same error. I have created a file of extension .pas, copied the code you have provided and compiled it. but it doesnt work. Nothing happens. Thankyou..... can you tell me the problem. I re-run the created exe file on cmd and this is the following response.
Exception EAccessViolation in module JkDefragLib.dll at 00008C27.
Access violation at address 10008C27 in module 'JkDefragLib.dll'. Write of addre
ss 00000002.
Logged
jeroen
Administrator
JkDefrag Hero
Posts: 7155
Re: Error Use Library In Delphi.
«
Reply #48 on:
June 12, 2008, 08:30:38 am »
Quote from: puma on June 12, 2008, 04:43:15 am
I tried the one provided in example but the story is same, Im facing the same error.
I am sorry, but I have no idea what the problem could be. Your statements about "same error" and "nothing happens" seem to be conflicting, and as far as I know the example should simply work. I am not a Delphi/Pascal programmer myself, so I have no suggestions. Sorry! If you find a solution then please let me know!
Logged
puma
Newbie
Posts: 4
Re: Error Use Library In Delphi.
«
Reply #49 on:
June 12, 2008, 11:36:58 am »
Ok thaks....... I have some querries.......
1) How do you get the VCN and LCN of cluster on which the file is copied thorugh FSCTL_GET_RETRIEVAL_POINTERS?
2) FSCTL_GET_VOLUME_BITMAP doesnt give information regarding the LCN and VCN of the clusters so how do I get this information which is used in FSCTL_GET_RETRIEVAL_POINTERS?
3) Does the cluster size matters?
Logged
jeroen
Administrator
JkDefrag Hero
Posts: 7155
Re: Error Use Library In Delphi.
«
Reply #50 on:
June 12, 2008, 05:58:57 pm »
Quote from: puma on June 12, 2008, 11:36:58 am
I have some querries.......
For more information about those function calls see the Microsoft manuals. For a working example see the sources of JkDefrag, the "JkDefragLib.cpp" file.
Quote
3) Does the cluster size matters?
No, not really. To move a file it's not necessary to know the cluster size.
Logged
C0derr
Newbie
Posts: 1
Re: Error Use Library In Delphi.
«
Reply #51 on:
November 07, 2010, 03:25:37 pm »
Hi everybody!
I have the same problem with using dll in Delphi.
Exception EAccessViolation in module JkDefragLib.dll at 00008C27.
Access violation at address 10008C27 in module 'JkDefragLib.dll'. Write of addre
ss 00000002.
Has anybody solved it?
PS: I used the example in src without any changes.
PSS: that's very important
«
Last Edit: November 07, 2010, 07:00:53 pm by C0derr
»
Logged
raybackjoe
Newbie
Posts: 1
Re: Error Use Library In Delphi.
«
Reply #52 on:
February 04, 2013, 07:28:49 pm »
Thanks for you replied.
Logged
Joe Rayback
Pages:
1
2
3
[
4
]
Print
« previous
next »
Jump to:
Please select a destination:
-----------------------------
MyDefrag v4 Forum
-----------------------------
=> Announcements
=> Questions and help
=> Bugs and problems
=> Requests for new features
=> Scripts, and other contributions
-----------------------------
JkDefrag v3 Forum
-----------------------------
=> Announcements
=> Questions and help
=> Bugs and problems
=> Requests for new features
=> Programming with the library
Loading...