Modify Array VB & PB with a DLL, please need help please :-(
Re: Modify Array VB & PB with a DLL, please need help please :-(
KCC - did you finally get this all figured out?
- Kwai chang caine
- Always Here
- Posts: 5494
- Joined: Sun Nov 05, 2006 11:42 pm
- Location: Lyon - France
Re: Modify Array VB & PB with a DLL, please need help please :-(
XOMBIE...very very thanks for make worry for the poor KCC 
In fact, after one month of search ....and several helps by you all...Us and French forum.
I have found nearly what i search.....
After a long long time and several successive problems....
1/How send a VB dynamical string array to PB ??
Fixed by SROD with the structure
2/How not use the exe pointers ??
I found this solution : "Copy in a new array in the DLL."
Like this i can use the new array, like i want, Dim, Redim, ArraySize, Add lines, Delete lines....
3/How return the array from DLL to exe caller ??
After try several method...i have choose the first found at the beginning: "The pointer of Array"
For my little head..it's the more simple
But i have changed the VB code, because before, i copy directly pointers of DLL array, in VB array
And when i free the VB exe array, i freeing in the same time the DLL pointers, because it's the same
And my error is here...
So now, i fixed that, in VB code i read in memory and copy array, without use the pointers, like this no risk of freeing
Finally, that works.....
But i have two regrets...
First.... i'm forced to send the size of array in VB code, otherwise the DLL can't know where stopped to read memory and that crash
Next...I'm forced too, to send a flag, for the DLL recognize, what is the exe, who call it
Because, if it's VB exe....the array is UNICODE, so i need PeekS(UNICODE)
And if it's PB exe....the array is ASCII, because i don't want compil in UNICODE, my DLL
I have the idea: "use TRUE", because in VB = -1 and for PB #True = 1 and multiply arraysize with true
After i test if the array value is negative, and if yes...the caller is VB
SROD say to me, it's not good to try to search in the memory if the array passing by the exe is or not UNICODE
And the "professional" method is to create two different functions...
I listen always my MASTER because he is very intelligent
But this time, his solution create problems to KCC
Two function by function......my DLL is already so big
So i have listen it, and stop to search solution, because it's difficult to use the API "istextunicode" if the DLL is not UNICODE (That's another member GEBONET who say that to me)
So....this is my cowpat code
For a MASTER like you, they are not one month of search, perhaps one hour
But apparently, SROD say to me, it's not a method use by the professionals
A DLL don't modify an exe array
Then.... i'm happy to create this code, even if it's not a regular method
Because...i repeat a little bit too much...but it's really the heart of hundred of my functions, and it's really important for me to create a good code
The first time...i have create a bad code ..and several softwares is bugged
If you can take a little bit of time to see, my code.
And if you found a method for not send sizearray or found if the array send is UNICODE, without compile the DLL in UNICODE....i'm very interesting
And obiously...if you see an error for the memory or other..i'm also interesting
Your advice is very very important for KCC
My code passing a VB and PB array dynamical string in DLL, modify the array (Replace five first "Sentence" word to "KCC"), add 2 lines, and return in the VB or PB exe
The second time, it reverse the function (Replace five first "KCC" word to "Sentence"), and always add 2 lines, and return in the VB or PB exe
In the ZIP, you have the caller of DLL PB, the caller of DLL VB, The exe VB caller of DLL, the EXCEL file caller of DLL (Like this you can try without VB6) , and obviously the code and the DLL
http://erdsjb.free.fr/PureStorage/Xombie.zip
I wish you a good day
And again sincerely thanks, to your interest

In fact, after one month of search ....and several helps by you all...Us and French forum.

I have found nearly what i search.....

After a long long time and several successive problems....
1/How send a VB dynamical string array to PB ??
Fixed by SROD with the structure

2/How not use the exe pointers ??
I found this solution : "Copy in a new array in the DLL."
Like this i can use the new array, like i want, Dim, Redim, ArraySize, Add lines, Delete lines....
3/How return the array from DLL to exe caller ??
After try several method...i have choose the first found at the beginning: "The pointer of Array"
For my little head..it's the more simple

But i have changed the VB code, because before, i copy directly pointers of DLL array, in VB array
And when i free the VB exe array, i freeing in the same time the DLL pointers, because it's the same

And my error is here...
So now, i fixed that, in VB code i read in memory and copy array, without use the pointers, like this no risk of freeing

Finally, that works.....
But i have two regrets...
First.... i'm forced to send the size of array in VB code, otherwise the DLL can't know where stopped to read memory and that crash

Next...I'm forced too, to send a flag, for the DLL recognize, what is the exe, who call it

Because, if it's VB exe....the array is UNICODE, so i need PeekS(UNICODE)
And if it's PB exe....the array is ASCII, because i don't want compil in UNICODE, my DLL
I have the idea: "use TRUE", because in VB = -1 and for PB #True = 1 and multiply arraysize with true

After i test if the array value is negative, and if yes...the caller is VB

SROD say to me, it's not good to try to search in the memory if the array passing by the exe is or not UNICODE

And the "professional" method is to create two different functions...
I listen always my MASTER because he is very intelligent

But this time, his solution create problems to KCC

Two function by function......my DLL is already so big

So i have listen it, and stop to search solution, because it's difficult to use the API "istextunicode" if the DLL is not UNICODE (That's another member GEBONET who say that to me)

So....this is my cowpat code

For a MASTER like you, they are not one month of search, perhaps one hour

But apparently, SROD say to me, it's not a method use by the professionals
A DLL don't modify an exe array

Then.... i'm happy to create this code, even if it's not a regular method

Because...i repeat a little bit too much...but it's really the heart of hundred of my functions, and it's really important for me to create a good code

The first time...i have create a bad code ..and several softwares is bugged

If you can take a little bit of time to see, my code.
And if you found a method for not send sizearray or found if the array send is UNICODE, without compile the DLL in UNICODE....i'm very interesting

And obiously...if you see an error for the memory or other..i'm also interesting

Your advice is very very important for KCC

My code passing a VB and PB array dynamical string in DLL, modify the array (Replace five first "Sentence" word to "KCC"), add 2 lines, and return in the VB or PB exe
The second time, it reverse the function (Replace five first "KCC" word to "Sentence"), and always add 2 lines, and return in the VB or PB exe
In the ZIP, you have the caller of DLL PB, the caller of DLL VB, The exe VB caller of DLL, the EXCEL file caller of DLL (Like this you can try without VB6) , and obviously the code and the DLL
http://erdsjb.free.fr/PureStorage/Xombie.zip
I wish you a good day
And again sincerely thanks, to your interest


Not a destination
Re: Modify Array VB & PB with a DLL, please need help please :-(
KCC,
I was off on a little trip since the end of last week so I didn't have a chance to look at this yet. I will look at what you have over the next few days to see if I'm able to help with anything. Perhaps I won't be very effective with all the other wonderful help you've received. I'll still take a look, however.
I was off on a little trip since the end of last week so I didn't have a chance to look at this yet. I will look at what you have over the next few days to see if I'm able to help with anything. Perhaps I won't be very effective with all the other wonderful help you've received. I'll still take a look, however.
- Kwai chang caine
- Always Here
- Posts: 5494
- Joined: Sun Nov 05, 2006 11:42 pm
- Location: Lyon - France
Re: Modify Array VB & PB with a DLL, please need help please :-(
Thanks XOMBIE
I'm happy to see, that if you don't answer, it's not the fault of my long THREAD
Because i say to me: "KCC.... you have frighten off XOMBIE, with all your questions and all your words"
Now i know it's a trip the reason of your silence
It's good to quit sometime the PC
But me...even in vacancy...i have a PC
I'm sure you can give an important advice.
Because, it's true, there are numerous members who helped me.
Each member gave to KCC a piece of code, a function and i thanks again each of them
But even with great code, when KCC assemble them, KCC can make a cowpat with beautiful flowers
My code works fine, but since the last time, when i used a code several time, and several functions
I seen, it don't works just after one month...
And now, i prefer ask at professional before have a second surprise
And be sure the memory of my PC, is not in sufferance
Again thanks for your interest
I wish you a good week
I'm happy to see, that if you don't answer, it's not the fault of my long THREAD

Because i say to me: "KCC.... you have frighten off XOMBIE, with all your questions and all your words"

Now i know it's a trip the reason of your silence

It's good to quit sometime the PC

But me...even in vacancy...i have a PC

I'm sure you can give an important advice.
Because, it's true, there are numerous members who helped me.
Each member gave to KCC a piece of code, a function and i thanks again each of them

But even with great code, when KCC assemble them, KCC can make a cowpat with beautiful flowers

My code works fine, but since the last time, when i used a code several time, and several functions
I seen, it don't works just after one month...

And now, i prefer ask at professional before have a second surprise

And be sure the memory of my PC, is not in sufferance

Again thanks for your interest

I wish you a good week


Not a destination