|
Posted by sachin on July 31, 2007, 4:52 am
Please log in for more thread options
Hi I am trying to access DLL function(Dll is developed in VC++).from
perl module.
Here is my code :
The following function is present in cfm.pm module.
sub CheckFileInTOC
{
my($FileIndex) = @_;
$GetHandle = new
Win32::API('perlfunction.dll','fnGetTOCContent','I','I');
# $GetHandle = new
Win32::API('clisocketsd.dll','fnInitCLISocket','I','I');
if(not defined $GetHandle) {
die "Can't import API fnGetTOCContent: $!\n";
}
show/hide quoted text
$ReturnVal = $GetHandle->Call($FileIndex);
print("We are in cfm module now\n");
}
DLL function is as follows
int fnGetTOCContent(int nFileName )
{
printf("Hello you are in dll\n");
return 1;
}
When I call CheckFileInTOC function of cfm.pm, it calls function from
DLL and prints on console :Hello You are in dll.
But after this statement I get the following error.
The instruction at "0x28040110"refernced memory at "0x00000004".The
memory could not be "written".
When I debug this Application error in perl.exe I again get 1 message
box displaying
Unhandled exception in perl.exe(PERL58.DLL):0xC0000005:Access
Violation.
Can anyone tell me what is the solution for this problem.
Thanks in advance.
|
|
Posted by Sisyphus on July 31, 2007, 8:47 am
Please log in for more thread options
show/hide quoted text
> Hi I am trying to access DLL function(Dll is developed in VC++).from
> perl module.
> Here is my code :
> The following function is present in cfm.pm module.
> sub CheckFileInTOC
> {
> my($FileIndex) = @_;
> $GetHandle = new
> Win32::API('perlfunction.dll','fnGetTOCContent','I','I');
> # $GetHandle = new
> Win32::API('clisocketsd.dll','fnInitCLISocket','I','I');
> if(not defined $GetHandle) {
> die "Can't import API fnGetTOCContent: $!\n";
> }
> $ReturnVal = $GetHandle->Call($FileIndex);
> print("We are in cfm module now\n");
> }
> DLL function is as follows
> int fnGetTOCContent(int nFileName )
> {
> printf("Hello you are in dll\n");
> return 1;
> }
> When I call CheckFileInTOC function of cfm.pm, it calls function from
> DLL and prints on console :Hello You are in dll.
> But after this statement I get the following error.
> The instruction at "0x28040110"refernced memory at "0x00000004".The
> memory could not be "written".
Looks to me that code should work.
Check that $FileIndex is in fact an integer.
If it is the number (eg) 9, that should be fine. But if it was the string
'9' (or a non-numeric string), that might cause problems. (I don't know if
Win32::API converts numeric strings to numbers as happily as perl does.)
Cheers,
Rob
|
|
Posted by Petr Vileta on July 31, 2007, 10:29 am
Please log in for more thread options
Sisyphus wrote:
show/hide quoted text
>> Hi I am trying to access DLL function(Dll is developed in VC++).from
>> perl module.
>> Here is my code :
>> The following function is present in cfm.pm module.
>> sub CheckFileInTOC
>> {
>> my($FileIndex) = @_;
>> $GetHandle = new
>> Win32::API('perlfunction.dll','fnGetTOCContent','I','I');
>> # $GetHandle = new
>> Win32::API('clisocketsd.dll','fnInitCLISocket','I','I');
>> if(not defined $GetHandle) {
>> die "Can't import API fnGetTOCContent: $!\n";
>> }
>> $ReturnVal = $GetHandle->Call($FileIndex);
>> print("We are in cfm module now\n");
>> }
>> DLL function is as follows
>> int fnGetTOCContent(int nFileName )
>> {
>> printf("Hello you are in dll\n");
>> return 1;
>> }
>> When I call CheckFileInTOC function of cfm.pm, it calls function from
>> DLL and prints on console :Hello You are in dll.
>> But after this statement I get the following error.
>> The instruction at "0x28040110"refernced memory at "0x00000004".The
>> memory could not be "written".
> Looks to me that code should work.
> Check that $FileIndex is in fact an integer.
> If it is the number (eg) 9, that should be fine. But if it was the
> string '9' (or a non-numeric string), that might cause problems. (I
> don't know if Win32::API converts numeric strings to numbers as
> happily as perl does.)
> Cheers,
> Rob
Every time I'm not sure if variable is numeric or string then I use some
like this
show/hide quoted text
$ReturnVal = $GetHandle->Call(1 * $FileIndex);
--
Petr Vileta, Czech republic
(My server rejects all messages from Yahoo and Hotmail. Send me your mail
from another non-spammer site please.)
|
|
Posted by sachin on August 1, 2007, 3:13 am
Please log in for more thread options
show/hide quoted text
> > Hi I am trying to access DLL function(Dll is developed in VC++).from
> > perl module.
> > Here is my code :
> > The following function is present in cfm.pm module.
> > sub CheckFileInTOC
> > {
> > my($FileIndex) = @_;
> > $GetHandle = new
> > Win32::API('perlfunction.dll','fnGetTOCContent','I','I');
> > # $GetHandle = new
> > Win32::API('clisocketsd.dll','fnInitCLISocket','I','I');
> > if(not defined $GetHandle) {
> > die "Can't import API fnGetTOCContent: $!\n";
> > }
> > $ReturnVal = $GetHandle->Call($FileIndex);
> > print("We are in cfm module now\n");
> > }
> > DLL function is as follows
> > int fnGetTOCContent(int nFileName )
> > {
> > printf("Hello you are in dll\n");
> > return 1;
> > }
> > When I call CheckFileInTOC function of cfm.pm, it calls function from
> > DLL and prints on console :Hello You are in dll.
> > But after this statement I get the following error.
> > The instruction at "0x28040110"refernced memory at "0x00000004".The
> > memory could not be "written".
> Looks to me that code should work.
> Check that $FileIndex is in fact an integer.
> If it is the number (eg) 9, that should be fine. But if it was the string
> '9' (or a non-numeric string), that might cause problems. (I don't know if
> Win32::API converts numeric strings to numbers as happily as perl does.)
> Cheers,
> Rob- Hide quoted text -
> - Show quoted text -
Well i have checked it , I am passing number only but still it is
getting crashed.
|
|
Posted by Robert May on July 31, 2007, 7:35 pm
Please log in for more thread options
show/hide quoted text
> Hi I am trying to access DLL function(Dll is developed in VC++).from
> perl module.
show/hide quoted text
> DLL function is as follows
> int fnGetTOCContent(int nFileName )
> {
> printf("Hello you are in dll\n");
> return 1;
> }
> When I call CheckFileInTOC function of cfm.pm, it calls function from
> DLL and prints on console :Hello You are in dll.
> But after this statement I get the following error.
> The instruction at "0x28040110"refernced memory at "0x00000004".The
> memory could not be "written".
> When I debug this Application error in perl.exe I again get 1 message
> box displaying
> Unhandled exception in perl.exe(PERL58.DLL):0xC0000005:Access
> Violation.
try making your DLL function look like this:
int STDCALL fnGetTOCContent(int nFileName )
{
printf("Hello you are in dll\n");
return 1;
}
See if that help.
Rob.
|
| Similar Threads | Posted | | Accessing listbox using perl? | May 16, 2007, 7:48 pm |
| Best module for accessing a website with REST API | March 18, 2009, 2:26 pm |
| Using external REXX function libraries with PERL | October 1, 2007, 2:40 pm |
| Can't call method on an undefined value at | June 27, 2005, 2:56 pm |
| Import Module/Function - Undefined subroutine | November 30, 2009, 11:53 am |
| How to handle input and output of a program executed by System function in perl | July 18, 2004, 2:31 pm |
| After adding some Perl modules in my SuSE 8.2 installation Amavis does not function anymore. | December 12, 2004, 2:04 pm |
| Problem with Net::SSH::Perl module | December 22, 2004, 12:38 pm |
| Problem using C module in perl | January 5, 2006, 5:03 am |
| Perl PPM NTLM module problem | May 20, 2009, 2:50 pm |
|