What is the Delphi equivalent for LPLONG?





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







2















I have to access several functions of a DLL written in c from Delphi (currently Delphi7).
I can do it without problems when the parameters are scalar
(thanks to the examples found in this great site!), but I have been stuck for some time when in the parameters there is a pointer to an array of Longs.



This is the definition in the header file of one of the functions:




BOOL __stdcall BdcValida (HANDLE h, LPLONG opcl);




(opcl is an array of longs)



And this is a portion of my Delphi code:



type
TListaOpciones= array of LongInt; //I tried with static array too!
Popcion = ^LongInt; //tried with integer, Cardinal, word...
var
dllFunction: function(h:tHandle; opciones:Popcion):boolean;stdcall;
arrayOPciones:TListaOpciones;
resultado:boolean;
begin
.....
I give values ​​to aHandle and array arrayOPciones
.....
resultado:=dllFunction(aHandle, @arrayopciones[0]);
end;


The error message when executing it is:




"Project xxx raised too many consecutive exceptions: access violation
at 0x000 .."




What is the equivalent in Delhpi for LPLONG? Or am I calling the function in an incorrect way?
Thank you!










share|improve this question























  • I must admit that I find the function call confusing, in that if opcl really is a pointer to an array, and not, say, a single variable, I don't see how the DLL knows how big that array is - that is to say there is no parameter telling it unless it is stored in whatever h is pointing to.

    – Dsm
    Jan 3 at 13:53











  • The DLL knows the size of the array, it varies depending on the context and we know it through functions of the dll that inform it.

    – Martín Castro Aguirrezabala
    Jan 3 at 14:02











  • You are saying there is a different function to set the array length for the DLL. Are you sure that you are setting it correctly? Maybe you are passing a value that is too high (probably by one).

    – dummzeuch
    Jan 3 at 14:16











  • Relevant bits of the code are missing to understand who and where the memory is allocated and freed and how the size of the array is passed.

    – Remko
    Jan 4 at 10:08


















2















I have to access several functions of a DLL written in c from Delphi (currently Delphi7).
I can do it without problems when the parameters are scalar
(thanks to the examples found in this great site!), but I have been stuck for some time when in the parameters there is a pointer to an array of Longs.



This is the definition in the header file of one of the functions:




BOOL __stdcall BdcValida (HANDLE h, LPLONG opcl);




(opcl is an array of longs)



And this is a portion of my Delphi code:



type
TListaOpciones= array of LongInt; //I tried with static array too!
Popcion = ^LongInt; //tried with integer, Cardinal, word...
var
dllFunction: function(h:tHandle; opciones:Popcion):boolean;stdcall;
arrayOPciones:TListaOpciones;
resultado:boolean;
begin
.....
I give values ​​to aHandle and array arrayOPciones
.....
resultado:=dllFunction(aHandle, @arrayopciones[0]);
end;


The error message when executing it is:




"Project xxx raised too many consecutive exceptions: access violation
at 0x000 .."




What is the equivalent in Delhpi for LPLONG? Or am I calling the function in an incorrect way?
Thank you!










share|improve this question























  • I must admit that I find the function call confusing, in that if opcl really is a pointer to an array, and not, say, a single variable, I don't see how the DLL knows how big that array is - that is to say there is no parameter telling it unless it is stored in whatever h is pointing to.

    – Dsm
    Jan 3 at 13:53











  • The DLL knows the size of the array, it varies depending on the context and we know it through functions of the dll that inform it.

    – Martín Castro Aguirrezabala
    Jan 3 at 14:02











  • You are saying there is a different function to set the array length for the DLL. Are you sure that you are setting it correctly? Maybe you are passing a value that is too high (probably by one).

    – dummzeuch
    Jan 3 at 14:16











  • Relevant bits of the code are missing to understand who and where the memory is allocated and freed and how the size of the array is passed.

    – Remko
    Jan 4 at 10:08














2












2








2








I have to access several functions of a DLL written in c from Delphi (currently Delphi7).
I can do it without problems when the parameters are scalar
(thanks to the examples found in this great site!), but I have been stuck for some time when in the parameters there is a pointer to an array of Longs.



This is the definition in the header file of one of the functions:




BOOL __stdcall BdcValida (HANDLE h, LPLONG opcl);




(opcl is an array of longs)



And this is a portion of my Delphi code:



type
TListaOpciones= array of LongInt; //I tried with static array too!
Popcion = ^LongInt; //tried with integer, Cardinal, word...
var
dllFunction: function(h:tHandle; opciones:Popcion):boolean;stdcall;
arrayOPciones:TListaOpciones;
resultado:boolean;
begin
.....
I give values ​​to aHandle and array arrayOPciones
.....
resultado:=dllFunction(aHandle, @arrayopciones[0]);
end;


The error message when executing it is:




"Project xxx raised too many consecutive exceptions: access violation
at 0x000 .."




What is the equivalent in Delhpi for LPLONG? Or am I calling the function in an incorrect way?
Thank you!










share|improve this question














I have to access several functions of a DLL written in c from Delphi (currently Delphi7).
I can do it without problems when the parameters are scalar
(thanks to the examples found in this great site!), but I have been stuck for some time when in the parameters there is a pointer to an array of Longs.



This is the definition in the header file of one of the functions:




BOOL __stdcall BdcValida (HANDLE h, LPLONG opcl);




(opcl is an array of longs)



And this is a portion of my Delphi code:



type
TListaOpciones= array of LongInt; //I tried with static array too!
Popcion = ^LongInt; //tried with integer, Cardinal, word...
var
dllFunction: function(h:tHandle; opciones:Popcion):boolean;stdcall;
arrayOPciones:TListaOpciones;
resultado:boolean;
begin
.....
I give values ​​to aHandle and array arrayOPciones
.....
resultado:=dllFunction(aHandle, @arrayopciones[0]);
end;


The error message when executing it is:




"Project xxx raised too many consecutive exceptions: access violation
at 0x000 .."




What is the equivalent in Delhpi for LPLONG? Or am I calling the function in an incorrect way?
Thank you!







delphi dll interop






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jan 3 at 13:36









Martín Castro AguirrezabalaMartín Castro Aguirrezabala

112




112













  • I must admit that I find the function call confusing, in that if opcl really is a pointer to an array, and not, say, a single variable, I don't see how the DLL knows how big that array is - that is to say there is no parameter telling it unless it is stored in whatever h is pointing to.

    – Dsm
    Jan 3 at 13:53











  • The DLL knows the size of the array, it varies depending on the context and we know it through functions of the dll that inform it.

    – Martín Castro Aguirrezabala
    Jan 3 at 14:02











  • You are saying there is a different function to set the array length for the DLL. Are you sure that you are setting it correctly? Maybe you are passing a value that is too high (probably by one).

    – dummzeuch
    Jan 3 at 14:16











  • Relevant bits of the code are missing to understand who and where the memory is allocated and freed and how the size of the array is passed.

    – Remko
    Jan 4 at 10:08



















  • I must admit that I find the function call confusing, in that if opcl really is a pointer to an array, and not, say, a single variable, I don't see how the DLL knows how big that array is - that is to say there is no parameter telling it unless it is stored in whatever h is pointing to.

    – Dsm
    Jan 3 at 13:53











  • The DLL knows the size of the array, it varies depending on the context and we know it through functions of the dll that inform it.

    – Martín Castro Aguirrezabala
    Jan 3 at 14:02











  • You are saying there is a different function to set the array length for the DLL. Are you sure that you are setting it correctly? Maybe you are passing a value that is too high (probably by one).

    – dummzeuch
    Jan 3 at 14:16











  • Relevant bits of the code are missing to understand who and where the memory is allocated and freed and how the size of the array is passed.

    – Remko
    Jan 4 at 10:08

















I must admit that I find the function call confusing, in that if opcl really is a pointer to an array, and not, say, a single variable, I don't see how the DLL knows how big that array is - that is to say there is no parameter telling it unless it is stored in whatever h is pointing to.

– Dsm
Jan 3 at 13:53





I must admit that I find the function call confusing, in that if opcl really is a pointer to an array, and not, say, a single variable, I don't see how the DLL knows how big that array is - that is to say there is no parameter telling it unless it is stored in whatever h is pointing to.

– Dsm
Jan 3 at 13:53













The DLL knows the size of the array, it varies depending on the context and we know it through functions of the dll that inform it.

– Martín Castro Aguirrezabala
Jan 3 at 14:02





The DLL knows the size of the array, it varies depending on the context and we know it through functions of the dll that inform it.

– Martín Castro Aguirrezabala
Jan 3 at 14:02













You are saying there is a different function to set the array length for the DLL. Are you sure that you are setting it correctly? Maybe you are passing a value that is too high (probably by one).

– dummzeuch
Jan 3 at 14:16





You are saying there is a different function to set the array length for the DLL. Are you sure that you are setting it correctly? Maybe you are passing a value that is too high (probably by one).

– dummzeuch
Jan 3 at 14:16













Relevant bits of the code are missing to understand who and where the memory is allocated and freed and how the size of the array is passed.

– Remko
Jan 4 at 10:08





Relevant bits of the code are missing to understand who and where the memory is allocated and freed and how the size of the array is passed.

– Remko
Jan 4 at 10:08












1 Answer
1






active

oldest

votes


















3














LONG maps to Longint, and LPLONG maps to ^Longint. So, you have translated that type correctly.



You have translated BOOL incorrectly though. It should be BOOL or LongBool in Delphi. You can use either, the former is an alias for the latter.



Your error lies in code or detail we can't see. Perhaps you didn't allocate an array. Perhaps the array is incorrectly sized. Perhaps the handle is not valid. Perhaps earlier calls to the DLL failed to check for errors.






share|improve this answer
























  • Thanks David, I've tried static and dynamic arrays, correctly allocated. The Handle is valid (it works in other functions of the dll). I think earlier calls to the DLL are not the problem (if I call another function instead it does not give an error) I will correct the BOOL and try

    – Martín Castro Aguirrezabala
    Jan 3 at 14:10






  • 1





    Changing the BOOL won't make a difference. Wherever your problem is, it's not in the code presented.

    – David Heffernan
    Jan 3 at 15:06












Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54023379%2fwhat-is-the-delphi-equivalent-for-lplong%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









3














LONG maps to Longint, and LPLONG maps to ^Longint. So, you have translated that type correctly.



You have translated BOOL incorrectly though. It should be BOOL or LongBool in Delphi. You can use either, the former is an alias for the latter.



Your error lies in code or detail we can't see. Perhaps you didn't allocate an array. Perhaps the array is incorrectly sized. Perhaps the handle is not valid. Perhaps earlier calls to the DLL failed to check for errors.






share|improve this answer
























  • Thanks David, I've tried static and dynamic arrays, correctly allocated. The Handle is valid (it works in other functions of the dll). I think earlier calls to the DLL are not the problem (if I call another function instead it does not give an error) I will correct the BOOL and try

    – Martín Castro Aguirrezabala
    Jan 3 at 14:10






  • 1





    Changing the BOOL won't make a difference. Wherever your problem is, it's not in the code presented.

    – David Heffernan
    Jan 3 at 15:06
















3














LONG maps to Longint, and LPLONG maps to ^Longint. So, you have translated that type correctly.



You have translated BOOL incorrectly though. It should be BOOL or LongBool in Delphi. You can use either, the former is an alias for the latter.



Your error lies in code or detail we can't see. Perhaps you didn't allocate an array. Perhaps the array is incorrectly sized. Perhaps the handle is not valid. Perhaps earlier calls to the DLL failed to check for errors.






share|improve this answer
























  • Thanks David, I've tried static and dynamic arrays, correctly allocated. The Handle is valid (it works in other functions of the dll). I think earlier calls to the DLL are not the problem (if I call another function instead it does not give an error) I will correct the BOOL and try

    – Martín Castro Aguirrezabala
    Jan 3 at 14:10






  • 1





    Changing the BOOL won't make a difference. Wherever your problem is, it's not in the code presented.

    – David Heffernan
    Jan 3 at 15:06














3












3








3







LONG maps to Longint, and LPLONG maps to ^Longint. So, you have translated that type correctly.



You have translated BOOL incorrectly though. It should be BOOL or LongBool in Delphi. You can use either, the former is an alias for the latter.



Your error lies in code or detail we can't see. Perhaps you didn't allocate an array. Perhaps the array is incorrectly sized. Perhaps the handle is not valid. Perhaps earlier calls to the DLL failed to check for errors.






share|improve this answer













LONG maps to Longint, and LPLONG maps to ^Longint. So, you have translated that type correctly.



You have translated BOOL incorrectly though. It should be BOOL or LongBool in Delphi. You can use either, the former is an alias for the latter.



Your error lies in code or detail we can't see. Perhaps you didn't allocate an array. Perhaps the array is incorrectly sized. Perhaps the handle is not valid. Perhaps earlier calls to the DLL failed to check for errors.







share|improve this answer












share|improve this answer



share|improve this answer










answered Jan 3 at 13:46









David HeffernanDavid Heffernan

523k348391232




523k348391232













  • Thanks David, I've tried static and dynamic arrays, correctly allocated. The Handle is valid (it works in other functions of the dll). I think earlier calls to the DLL are not the problem (if I call another function instead it does not give an error) I will correct the BOOL and try

    – Martín Castro Aguirrezabala
    Jan 3 at 14:10






  • 1





    Changing the BOOL won't make a difference. Wherever your problem is, it's not in the code presented.

    – David Heffernan
    Jan 3 at 15:06



















  • Thanks David, I've tried static and dynamic arrays, correctly allocated. The Handle is valid (it works in other functions of the dll). I think earlier calls to the DLL are not the problem (if I call another function instead it does not give an error) I will correct the BOOL and try

    – Martín Castro Aguirrezabala
    Jan 3 at 14:10






  • 1





    Changing the BOOL won't make a difference. Wherever your problem is, it's not in the code presented.

    – David Heffernan
    Jan 3 at 15:06

















Thanks David, I've tried static and dynamic arrays, correctly allocated. The Handle is valid (it works in other functions of the dll). I think earlier calls to the DLL are not the problem (if I call another function instead it does not give an error) I will correct the BOOL and try

– Martín Castro Aguirrezabala
Jan 3 at 14:10





Thanks David, I've tried static and dynamic arrays, correctly allocated. The Handle is valid (it works in other functions of the dll). I think earlier calls to the DLL are not the problem (if I call another function instead it does not give an error) I will correct the BOOL and try

– Martín Castro Aguirrezabala
Jan 3 at 14:10




1




1





Changing the BOOL won't make a difference. Wherever your problem is, it's not in the code presented.

– David Heffernan
Jan 3 at 15:06





Changing the BOOL won't make a difference. Wherever your problem is, it's not in the code presented.

– David Heffernan
Jan 3 at 15:06




















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54023379%2fwhat-is-the-delphi-equivalent-for-lplong%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

android studio warns about leanback feature tag usage required on manifest while using Unity exported app?

SQL update select statement

WPF add header to Image with URL pettitions [duplicate]