© J.C. Kessels 2009
MyDefrag Forum
May 22, 2013, 12:26:49 am
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
>
Fustrated... Access Violation
Pages: [
1
]
« previous
next »
Print
Author
Topic: Fustrated... Access Violation (Read 8961 times)
Matt
Guest
Fustrated... Access Violation
«
on:
November 13, 2006, 10:28:51 am »
Jereon,
First, let me take the opportunity to thank you for such an excellent application. I liked it so much, I decided to write a utility that relied upon the dll you provided. It was at this point where I became known as an "un-happy camper". :-)
In both Visual Basic 6 and Delphi 6 and 2006, shortly after my call to RunDefrag I get an access violation at 10006278. Both environments, same address.
To further frustrate my efforts, I can't figure out what your linking too when building the dll. In both VC6 and in VC 2005 I receive between 102 and 105 errors. The headers and libs I'm trying to use are from the Windows Server 2003 R2 Platform SDK. I was hoping to build a checked version of the library to aid in my debugging, but obviously this isn't working for me....
Any help would be appreciated. Perhaps my ports of your header file is incorrect. If your familar with VB or Delphi and would care too have a look, I'll gladly send them.
Thanks for sharing such a great application with the open source community.
Matt
Logged
jeroen
Administrator
JkDefrag Hero
Posts: 7155
Re: Fustrated... Access Violation
«
Reply #1 on:
November 13, 2006, 10:06:01 pm »
Quote from: "Matt"
In both Visual Basic 6 and Delphi 6 and 2006, shortly after my call to RunDefrag I get an access violation at 10006278. Both environments, same address.
That message and number mean nothing to me. Do you have more information? Maybe a stacktrace, so I can see in which subroutine the program is at that time?
Quote from: "Matt"
To further frustrate my efforts, I can't figure out what your linking too when building the dll.
You are using the exact same SDK that I am using. Can you give some examples of the error messages you are getting? To compile everything from the commandline I have a little .bat file containing the following three lines:
Code:
@call "c:\Program Files\Microsoft Visual C++ Toolkit 2003\vcvars32.bat"
@call "C:\Program Files\Microsoft Platform SDK\SetEnv.Cmd" /2000 /RETAIL
nmake
Quote from: "Matt"
Perhaps my ports of your header file is incorrect. If your familar with VB or Delphi and would care too have a look, I'll gladly send them.
I am not familiar with VB and Delphi, but I know other readers on this forum that are, so perhaps if you post your code then maybe somebody else can help you?
Logged
Matt
Guest
Fustrated... Access Violation
«
Reply #2 on:
November 14, 2006, 10:15:34 am »
I've located the source of the access violation. I had two small problems. The first was a porting error in the last param of DllInitiliaze - there is more than one level of indirection on that pointer, the second was just dumb - in a single callback definition, for some reason I didn't declare it as stdcall, while I did with all the others.....
Regarding compiling the dll, my sdk is a fresh install, however I'm getting loads of errors?? Here's a sample:
Common2.c(143) : error C2079: 'Time' uses undefined struct '__timeb64'
Common2.c(150) : warning C4013: '_ftime64' undefined; assuming extern returning
int
Common2.c(151) : error C2224: left of '.time' must have struct/union type
Common2.c(151) : error C2224: left of '.millitm' must have struct/union type
Common2.c(159) : error C2224: left of '.time' must have struct/union type
Common2.c(159) : error C2224: left of '.millitm' must have struct/union type
Common2.c(1407) : error C2079: 'Time' uses undefined struct '__timeb64'
Common2.c(1413) : error C2224: left of '.time' must have struct/union type
Common2.c(1413) : error C2224: left of '.millitm' must have struct/union type
Common2.c(1485) : error C2224: left of '.time' must have struct/union type
Common2.c(1485) : error C2224: left of '.millitm' must have struct/union type
Common2.c(2245) : error C2079: 'Time' uses undefined struct '__timeb64'
Common2.c(2389) : error C2224: left of '.time' must have struct/union type
Common2.c(2389) : error C2224: left of '.millitm' must have struct/union type
Thanks for your time, and for the great library.
Matt
Logged
jeroen
Administrator
JkDefrag Hero
Posts: 7155
Fustrated... Access Violation
«
Reply #3 on:
November 14, 2006, 12:54:49 pm »
I think the problem is that you are trying to compile "common2.c" into an .obj file. But the "common1.c" and "common2.c" files are not standalone source files and cannot be compiled into .obj files. They are supposed to be included with "#include" in a source that you write. In your source you should also #include a series of system .h files, for example "sys/timeb.h" which contains the definitions for things like "__timeb64" and "_ftime64", and you need to write some subroutines that are expected by the defragger library. For examples see "defragdll.cpp", "defrag.c", and "windefrag.cpp".
To put it another way, you only have to compile "DefragDll.cpp". Do not include the "common" files in your project.
Much easier (and for Delphi and VBasic the only way) is to simply call the "DefragDll.dll" in your program. The DLL is pre-compiled by me and comes with the sources, you don't need to recompile. I cannot tell you exactly how to call the DLL from Delphi and VBasic, but it's basically the same as with any other DLL and I am told it's relatively easy. See the "DefragDLL.h" file for the definitions of the functions that you can call.
Logged
Matt
Guest
Fustrated... Access Violation
«
Reply #4 on:
November 14, 2006, 01:59:54 pm »
Yes, I have it working with Delphi now. The only reason I wanted to recompile it was too create a DEBUG version.
When I get a little more time I'll try to figure out what I'm doing wrong with regards to building it (curious to know what it is I'm doing wrong).
Anyhow, I've got an application working now using the dll, so I'm now a "happy camper" :-)
Thanks,
Matt
Logged
jeroen
Administrator
JkDefrag Hero
Posts: 7155
Fustrated... Access Violation
«
Reply #5 on:
November 14, 2006, 11:58:46 pm »
Perhaps you would like to share your Delphi code? I'm sure other people will greatly appreciate it.
Logged
Matt
Guest
Fustrated... Access Violation
«
Reply #6 on:
November 15, 2006, 12:33:17 pm »
Sure, now that I know where my error was in Delphi, I'm pretty sure if I make the same changes to the VB project it will work as well.
I'll email you the sample projects showing how to call the dll with VB or Delphi here soon (I'll try to tomorrow), I'm a little busy right now.
Matt
Logged
campagnol54
JkDefrag Junior
Posts: 7
Source code for VB6
«
Reply #7 on:
February 18, 2007, 03:51:13 pm »
Hi Matt
I need to use JKDefrag through my company net
I'm trying to use JKDefrag in VB6
Can't imagine that a simple declaration as this one doesn't work :
Declare Function StopDefrag Lib "JKDefrag" (ByVal WaitForIt As Integer) As Integer
i simply do this in debug window :
? StopDefrag(&0)
and i get a 49 error (problem with declaration parameters)
Can you share your source code ? I think it is expected by many users.
Thanks for your reply
Logged
jeroen
Administrator
JkDefrag Hero
Posts: 7155
Re: Source code for VB6
«
Reply #8 on:
February 18, 2007, 07:45:08 pm »
Quote from: "campagnol54"
? StopDefrag(&0)
I don't know VB, but I think the parameter should be without an ampersand?
Logged
campagnol54
JkDefrag Junior
Posts: 7
Fustrated... Access Violation
«
Reply #9 on:
February 19, 2007, 08:37:15 am »
Hi Jeroem
Great software !
I tried also :
? StopDefrag(0)
and
Declare Function StopDefrag Lib "JKDefrag" (ByVal WaitForIt As long) As long
but always the same reply : error 49
Logged
jeroen
Administrator
JkDefrag Hero
Posts: 7155
Fustrated... Access Violation
«
Reply #10 on:
February 19, 2007, 05:22:53 pm »
Ok, I was only guessing. The parameter is definitely an integer, not a long. See the "JkDefragDll.h" file in the sources for the exact definitions.
Logged
Pages: [
1
]
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...