Page 2 of 3

Posted: Fri May 29, 2009 3:27 pm
by thearr
Kwaï chang caïne wrote:If you have the same code, who don't crash the RAD....i'm interesting :D
Because i prefer close the VB with the button "quit" :lol:
I haven't got the code, because I haven't got VB and can't test the code I post.

So, the next step: I think that the possible problem why VB crashes is that DLL tries to free memory, allocated for the array, after the procedure is done. You can test if it's so if you change a DLL code a little:

Code: Select all

ProcedureDLL MyFunctionPB(*ArrayFromVB)
 Dim MyArray.l(1)
 CopyMemory(*ArrayFromVB, @MyArray(), 2*4)
 MessageRequester(PeekS(MyArray(0)), PeekS(MyArray(1)))
EndProcedure

Posted: Fri May 29, 2009 3:34 pm
by Kaeru Gaman
Kwaï chang caïne wrote:... since the beginning of the big adventure of "KCC in the land of the programming"
oh boy, why didn't you take the blue pill... :?

*joke* :wink:

Posted: Fri May 29, 2009 3:50 pm
by Kwai chang caine
Jester KCC wrote:If you have the same code, who don't crash the RAD....i'm interesting
Because i prefer close the VB with the button "quit"
Don't worry and not offense :D
It's french humor :D
I have all my trust in you 8)
And you help me very much

And the winner is.....THEARR !!!!

You have right, your new code works fine.
I can use my "quit button" for VB now :D

You are an ANGEL and an angel must have wifes

It's the reason why ............KCC is proud, to offer you, for thanks of your great and kindness help, a nice picture of your "Charlie's Angels" after a big french lunch :D
France it's the land of food :roll:

I hope it's a good present for you :roll:
I make you a big smile with

Image

Again thanks at you, and all help me, in this dangerous mission, in the middle of the PC memory :?

PS: It's not a sex picture.
All this "angels" (I believe she can't fly :?) are dressed.
If you don't see their knikers....perhaps it is too small :D

Posted: Fri May 29, 2009 6:10 pm
by Fluid Byte
What the hell ... :shock:

Posted: Fri May 29, 2009 7:17 pm
by Kwai chang caine
Apparently.....you don't like too, my THEARR present :cry:

Posted: Fri May 29, 2009 7:23 pm
by Fluid Byte
Sir Mix-A-Lot - I Like Big Butts wrote:I like big butts and I can not lie
You other brothers can't deny
That when a girl walks in with an itty bitty waist
And a round thing in your face
You get sprung
...

Posted: Fri May 29, 2009 7:59 pm
by Kwai chang caine
Aaaahhhh yeeeess !!!!!
KCC have understand what you try to say to me....

This super nice girls is "rappers" :D
That's the sisters of the fat boys :lol:

Posted: Wed Jun 03, 2009 10:06 am
by Kwai chang caine
thearr wrote:
Kwaï chang caïne wrote:And i obtain a msgbox with a "o" in the titlebar and a "t" in the prompt :shock:
When i click ok......VB crash

KCC is very very sad :cry:
OK, we've almost got it.

Now try to chek "Unicode executable" option in PB IDE before compiling DLL.
It's again me :oops:

The passing of array works fine now, thanks to THEARR, but when i pass a string variable at my DLL i have square character in the messagerequester :shock:

Code: Select all

ProcedureDLL MyFunctionPB(String.s, *ArrayFromVB) 
 MessageRequester("", String)
 Dim MyArray.l(1) 
 CopyMemory(*ArrayFromVB, @MyArray(), 2*4) 
 MessageRequester(PeekS(MyArray(0)), PeekS(MyArray(1))) 
EndProcedure
Then i disable the UNICODE in the DLL, my string is OK, but i have just the first character of my array :cry:

Someone know what i must do ????? :roll:
Programming is really the HELL for KCC :cry:

Posted: Wed Jun 03, 2009 11:01 am
by Kwai chang caine
Well...it's christmas :D
KCC have found alone the solution...like a big :shock:

KCC think the problem is in the side of VB :roll:

So KCC add this line in the VB code :

Code: Select all

Private Declare Sub MyFunctionPB Lib "c:\MyDll.dll" (ByRef MyArray As Long) 

Public Sub Form_Load() 
  
 MyArrayVB(0) = "one" 
 MyArrayVB(1) = "two" 
 
 MyStr = StrConv(MyArrayVB(0), vbFromUnicode)
 MyArrayPB(0) = StrPtr(MyStr) 
 
 MyStr = StrConv(MyArrayVB(1), vbFromUnicode)
 MyArrayPB(1) = StrPtr(MyStr) 
  
 MyFunctionPB MyArrayPB(0) 'Send pointer to PB DLL function (ByRef) 

End Sub
And "Roll my hen" (French expression = "Roule ma poule")....that's works fine now :D

If this........... can help anybody a day :wink:

Posted: Wed Jun 03, 2009 4:08 pm
by helpy

Posted: Wed Jun 03, 2009 4:50 pm
by Kwai chang caine
Thanks HELPY for your links. 8)
I try to understand it :oops:

I have send the skin of bear to quickly :oops:

This function of VB don't works

Code: Select all

MyStr = StrConv(TabloVB(i), vbFromUnicode)
I must convert UNICODE to ANSI in VB not in PB
I have found a function who convert UNICODE/ANSI in PB and that's works

But i search the same function vor VB and don't find it :cry:

Posted: Wed Jun 03, 2009 8:11 pm
by thearr
Kwaï chang caïne wrote:The passing of array works fine now, thanks to THEARR, but when i pass a string variable at my DLL i have square character in the messagerequester :shock:

Code: Select all

ProcedureDLL MyFunctionPB(String.s, *ArrayFromVB) 
 MessageRequester("", String)
 Dim MyArray.l(1) 
 CopyMemory(*ArrayFromVB, @MyArray(), 2*4) 
 MessageRequester(PeekS(MyArray(0)), PeekS(MyArray(1))) 
EndProcedure
I don't know how do you pass the string, but this way can work:

Code: Select all

Private Declare Sub MyFunctionPB Lib "c:\MyDll.dll" (ByVal MyString as String, ByRef MyArray As Long) 


MyFunctionPB TestString, MyArrayPB(0) 'TestString is a string variable you'd like to pass to Dll

Posted: Wed Jun 03, 2009 9:59 pm
by Kwai chang caine
Hello THEARR :D

Yes that's works only if i compile in UNICODE the DLL :cry:
But if i compile in UNICODE it's the title string who don't pass.

I prefer convert in VB the UNICODE to ANSI and pass the array in ANSI mode, if it's possible.
At my mean it's more simple, and like i have never compiled all my DLL in UNICODE, i'm affraid if one or much more variable don't pass :cry:

I have try also to compile in ANSI and add this function

Code: Select all

Procedure.s Unicode2Ansi(*Unicode, UniLen.l) 
  ;/ *Unicode [in]  Points To the wide-character string To be converted. 
  ;/ UniLen   [in]  Specifies the number of wide characters in the string pointed to by the lpWideCharStr parameter. If this value is -1, the string is assumed to be null-terminated and the length is calculated automatically. The length will include the null-terminator. 
  ;/ string   [out] The translated (ANSI) string. 
  Protected Ansi.s,AnsiLen.l 
  AnsiLen = WideCharToMultiByte_(#CP_ACP,0,*Unicode,UniLen,0,AnsiLen,0,0) 
  If AnsiLen 
    Ansi = Space(AnsiLen) 
    If WideCharToMultiByte_(#CP_ACP,0,*Unicode,UniLen,@Ansi,AnsiLen,0,0);"•",#True) 
      ProcedureReturn Ansi 
    EndIf 
  EndIf 
  ProcedureReturn "" 
EndProcedure
 

Code: Select all

  Ansi.s = Unicode2Ansi(MyArray(i), 1000)
  AddGadgetItem(#ListviewTexte, - 1, ReplaceString(Ansi, Chr(13), ""))
And that's works fine too.
But i search to convert in VB in ANSI not in PB
Because i don't want to modify all my DLL :roll:

Posted: Wed Jun 03, 2009 11:03 pm
by thearr
:?:

Code: Select all

 MyArrayVB(0) = StrConv("one", vbFromUnicode)
 MyArrayVB(1) = StrConv("two", vbFromUnicode) 

Posted: Thu Jun 04, 2009 7:51 am
by Kwai chang caine
Ooouuuiinnn !!!!
KCC become crazy....Ooouuuiinnn !!!!
Image
KCC don't understand anything now...Ooouuuiinnn !!!!
UNICODE, ANSI, MEMORY, POINTER, VB, SAFEARRAY, PB ....oouuuiinnn !!!!

KCC just want pass a string array of VB to PB...is just that ...only that.......Oiuiinnn !!!!
The programming is very bad with KCC .....Oiuiinnn !!!!

KCC have an idea :?:
This is the VB code and PB code of KCC :D

http://erdsjb.free.fr/TabloDll.zip

Perhaps you, you can do a magical tower and pass this #([**@"=## of array of VB to PB :roll: