PDA

View Full Version : Weird Problem With PB DLL Calls



RizlaUK
02-16-2008, 06:16 PM
i having a nightmare here,

trying to make (yet another) dll and im having this strange error passing strings to the dll file,

it seems that if i pass any more than 1 string to the dll it just gets lost, PB dosent seem to be reading it, iv gone through the PB forums and couldent find anything so i thought i would ask here.

i made this quick demo to test there was nothing in my dll causing a problem


ProcedureDLL.s DatePickerDialog(Date$, WinTitle$, BannerText$, DateType, MonthType, DayType, hWnd)

#EOL=Chr(10)+Chr(13)
test$="WinTitle: "+ WinTitle$ +#EOL
test$+"SelDate: "+ Date$ +#EOL
test$+"BannerText: "+ BannerText$ +#EOL
test$+"DateType: "+Str(DateType)+#EOL
test$+"MonthType: "+Str(MonthType)+#EOL
test$+"DayType: "+Str(DayType)+#EOL
test$+"hWnd: "+Str(hWnd)+#EOL


MessageRequester("Recived Args",test$,0)

EndProcedure


and called it from AMS with

--Test
WinTitle="Date Picker Test"
SelDate="qwerty"
BannerText="Bannet Text Test"
DateType=1
MonthType=1
DayType=1
hWnd=Application.GetWndHandle()

Args="\""..WinTitle.."\", \""..SelDate.."\", \""..BannerText.."\", "..DateType..", "..MonthType..", "..DayType..", "..hWnd

Dialog.Message("Sent Args", Args);

result = DLL.CallFunction("AutoPlay\\Docs\\TEST.dll", "DatePickerDialog", Args, DLL_RETURN_TYPE_STRING, DLL_CALL_STDCALL);

Dialog.Message("Notice", result);

only the 1st string gets passed, the 2nd and 3rd just seem to get lost, and the intergers also get passed (after the lost strings)

has anyone else encountered this ?

could someone please run the above code and tell me it works so i can take a hammer to this pc and have a excuse to get a new one for me BDay ;)

RizlaUK
02-16-2008, 06:38 PM
well i kinda got round my problem by passing 1 single string and useing StringField to split it

but this is not right, iv made dll's that accecpet 6 or 7 strings and they worked fine, why is this doing this now, virus, trojan, im starting to wonder, its got me beat :huh

TimeSurfer
02-18-2008, 01:34 PM
Rizla,
I ran into this problem as well when I made RegXmATCH. I also needed to pass 2 strings and 1 long to the dll. Here's how I got around it. ;)

Granted this is a global function from one of my projects but you should understand it, your far better wit ams then i. The variables and code that have to do with the dll are in red. [Notice how i had to escape the crap outta the string vars lol]


function GetFiles()
sFile = File.Find(Shell.GetFolder(SHF_MYDOCUMENTS), "*.*", false, false, ShowSearchProgress, nil);
if sFile then
for i,v in sFile do
tbSplit = String.SplitPath(v);
name = tbSplit.Filename
ext = tbSplit.Extension
tblNodeData = {};
tblNodeData.Text = name..""..ext;
tblNodeData.Data = v;
text = "\""..ext.."\""
regex = "\"(.r\\d|.R\\d)(\\d)\""
match = 1
params = text..","..regex..","..match
regchk = DLL.CallFunction("AutoPlay\\Docs\\RegXmATCH.dll", "RegMatch", params, DLL_RETURN_TYPE_STRING, DLL_CALL_STDCALL);
if regchk == "1" then
tblNodeData.ImageIndex = 29
end
Tree.InsertNode("Tree1", "0", tblNodeData);
end
end
end

Worm
02-18-2008, 02:18 PM
This is the way I set mine up. Define the parameters with the .s, .l, .d , etc... and then define your variables within the procedure too.



ProcedureDLL.s DatePickerDialog(date.s, WinTitle.s, BannerText.s, DateType.l, MonthType.l, DayType.l, hwnd.l)

#EOL = Chr(10) + Chr(13)
test.s = "WinTitle: " + WinTitle + #EOL
test = test + "SelDate: " + date +#EOL
test = test + "BannerText: " + BannerText +#EOL
test = test + "DateType: " + Str(DateType)+#EOL
test = test + "MonthType: " + Str(MonthType)+#EOL
test = test +"DayType: " + Str(DayType)+#EOL
test= test + "hWnd: " + Str(hwnd) + #EOL


MessageRequester("Received Args",test,0)

EndProcedure

Intrigued
02-18-2008, 06:54 PM
I do it Worm's way, save for the #EOL (nice!)

RizlaUK
05-02-2008, 11:26 PM
ah, i discoverd what is causeing this!!!

im making some more dll's for AMS and im passing strings to the dll, once again only the 1st string sent was being reviced by the dll but all numbers are ok

spot the differance

This one works fine

local Title="My Title"
local Message="My Message"
local Default=Shell.GetFolder(SHF_PROGRAMFILES).."\\";
local X=-1
local Y=-1
local BackCol=0
local FrontCol=255
local args = "\""..Title.."\",\""..Message.."\",\""..Default.."\","..X..","..Y..","..BackCol..","..FrontCol..","..Application.GetWndHandle()
result = DLL.CallFunction("AutoPlay\\Docs\\DialogEX.dll", "Open_FolderDlg", args, DLL_RETURN_TYPE_STRING, DLL_CALL_STDCALL);

this one the strings get lost

local Title="My Title"
local Message="My Message"
local Default=Shell.GetFolder(SHF_PROGRAMFILES).."\\";
local X=-1
local Y=-1
local BackCol=0
local FrontCol=255
local args = "\""..Title.."\", \""..Message.."\", \""..Default.."\", "..X..","..Y..", "..BackCol..", "..FrontCol..", "..Application.GetWndHandle()
result = DLL.CallFunction("AutoPlay\\Docs\\DialogEX.dll", "Open_FolderDlg", args, DLL_RETURN_TYPE_STRING, DLL_CALL_STDCALL);


it seems adding a space between the string arguments was causeing PB not to read them, remove the space and it all works fine

strange huh!!

Intrigued
05-03-2008, 09:42 PM
Interesting find...