Not being funny, but TCP is a perfect way for applications to talk to each other in Blitz... Grey Aliens solution means that your hard drive will be accessed every second, just think what that will do for the read/write speed of other applications!
About your problems:-
1) Windows API is a collection of 'open' functions within Windows that let programmers harness the power (if you will) of the OS... The key to harnessing this extra function ability (if you will), is by reading the read me file in your blitz+root/userlibs/ folder.. or, you could just do this:-
1) Create a file in your user lib folder called "WinAPI.DECLS"... e.g. "C:\Program Files\BlitzPlus\userlibs\WinAPI.DECLS"
Now, type this in the file and save:-
.lib "Advapi32.dll"
GetUserName%(strBuffer*,wSize*):"GetUserNameA"
This is a command within WinAPI that returns the name of the current user of windows... now don't be fooled, because unlike Blitz+ functions, the name is actually returned in the parameter, this function (in Blitz terms) returns an integer, corresponding to the amount of characters copied.
The best way to descibe this is by showing an example... If you wrote the DECLS file correctly, fire up Blitz+, and run this:-
WinAPI sits in your C:\Windows\System32\ folder (That where the .lib file 'Advapi32.dll' is.. if you wanna peek), The best thing to do is search in MSDN for WinAPI32, and also, read the read me file I mentioned earlier
Now, regarding PostMessage and SendMessage... I'm sure Blitz+ uses these functions, because these functions are used for messages between Windows, and an app... You would have to write your own DLL, with it's own callback function, and if you don't now C\C++, your knackered!
Now don't get me wrong, it may be possible to do what you want to do, but TCP is the easy... non hard drivin option... and if you don't understand TCP... here's an example of a real life app that uses it:-
CLIENT:
If TCP is not your answer, well, I've tried, but good luck on your project anyway!
Dabz
Note: I only mentioned ExecFile, because if it boils down to your application being two or more seperate applications, you could fire up each application using ExecFile, then use a TCP mechanism to communicate between them!
About your problems:-
1) Windows API is a collection of 'open' functions within Windows that let programmers harness the power (if you will) of the OS... The key to harnessing this extra function ability (if you will), is by reading the read me file in your blitz+root/userlibs/ folder.. or, you could just do this:-
1) Create a file in your user lib folder called "WinAPI.DECLS"... e.g. "C:\Program Files\BlitzPlus\userlibs\WinAPI.DECLS"
Now, type this in the file and save:-
.lib "Advapi32.dll"
GetUserName%(strBuffer*,wSize*):"GetUserNameA"
This is a command within WinAPI that returns the name of the current user of windows... now don't be fooled, because unlike Blitz+ functions, the name is actually returned in the parameter, this function (in Blitz terms) returns an integer, corresponding to the amount of characters copied.
The best way to descibe this is by showing an example... If you wrote the DECLS file correctly, fire up Blitz+, and run this:-
Print "The current user is:"+CurrentUser$() Delay 5000 Function CurrentUser$() bnkName = CreateBank(256) bnkSize = CreateBank(1) PokeByte(bnkSize,255,0) GetUserName(bnkName,bnkSize) ;<---- Userlib function we wrote earlier copiedChar = PeekByte(bnkSize,0) For loop = 0 To copiedChar-1 userName$ = userName$ + Chr$(PeekByte(bnkName,loop)) Next Return(Left(userName$,(Len(userName$)-1))) End Function
WinAPI sits in your C:\Windows\System32\ folder (That where the .lib file 'Advapi32.dll' is.. if you wanna peek), The best thing to do is search in MSDN for WinAPI32, and also, read the read me file I mentioned earlier
Now, regarding PostMessage and SendMessage... I'm sure Blitz+ uses these functions, because these functions are used for messages between Windows, and an app... You would have to write your own DLL, with it's own callback function, and if you don't now C\C++, your knackered!
Now don't get me wrong, it may be possible to do what you want to do, but TCP is the easy... non hard drivin option... and if you don't understand TCP... here's an example of a real life app that uses it:-
CLIENT:
;Client ;May use userlibs (you'll probably find them in Bit's and Bobs of ;the userlib section of BB.COM ;Check client drive ;checkDrivetype = GetDriveType(Left$(SystemProperty$("appdir"),3)) ;If checkdrivetype <> 2 ; Notify "Please run client from a removable drive."+Chr$(13)+"e.g. floppy/USB data stick" ; End ;End If ;Global password$ = "dabz" Global targetDir$ = SystemProperty("tempdir") Global win = CreateWindow("Dabz Remote Media Suite (Client)",100,100,375,425,Desktop(),15) Global lblIPlabel = CreateLabel("Connect to I.P. Address:-",60,20,130,20,win) Global tbIPaddress = CreateTextField(200,15,100,20,win) Global lblPassword = CreateLabel("Password:-",60,50,70,20,win) Global txtPassword = CreateTextField(130,45,100,20,win,True) Global btnConnect = CreateButton("Connect...",240,45,60,20,win) Global lblNowt = CreateLabel("______________________________________________________",20,70,350,20,win) Global remoteDirButton = CreateButton("Read Remote Directory",110,105,130,20,win) Global download = CreateButton("Download",195,260,70,20,win) Global btnFileSize = CreateButton("Request File Size",85,260,100,20,win) DisableGadget btnFileSize DisableGadget download DisableGadget remoteDirButton Global remoteDirIndex = CreateListBox(60,145,235,100,win) Global lblTargetDir = CreateLabel("Target Directory:-",60,300,100,20,win) Global btnTargetDir = CreateButton(". . .",265,320,30,20,win) Global tbTargetDir = CreateTextField(60,320,200,20,win) SetGadgetText(tbTargetDir,targetDir$) Global alertConnection = LoadSound("ding.wav") Global menu = WindowMenu(win) Global localCommand = CreateMenu("Local",0,menu) CreateMenu("Change Target Directory",1,localCommand) CreateMenu("",0,localCommand) CreateMenu("Open 'Code Page' URL",2,localCommand) CreateMenu("Decrypt 'Code Page' Code",3,localCommand) CreateMenu("",0,localCommand) CreateMenu("Close Client",9,localCommand) Global remoteCommand = CreateMenu("Remote",0,menu) CreateMenu("Request Server Log",10,remoteCommand) CreateMenu("Re-enable Server (If hidden)",11,remoteCommand) CreateMenu("",0,remoteCommand) CreateMenu("Shutdown Server and Close Client",12,remoteCommand) DisableMenu remoteCommand Global help = CreateMenu("Help",0,menu) CreateMenu("Dabz Remote Media Suite Online Help",20,help) CreateMenu("",0,help) CreateMenu("About Dabz Remote Media Suite (Client)",21,help) UpdateWindowMenu win Dim ipDecrypt(15) Repeat event = WaitEvent(10) If event = $803 If dontclose = False End Else Notify "Please click the 'FINISH' button." End If End If If event = $1001 menuItem = EventData() Select menuItem Case 1 targetDir$ = RequestDir$("Change target folder:-") If Right$(targetDir$,1) <> "" Then targetDir$ = targetDir$ + "" If targetDir$ = "" Then targetDir$ = SystemProperty("tempdir") SetGadgetText(tbTargetDir,targetDir$) Case 2 openIPwin = CreateWindow("Open 'Code Page'",GadgetX(win),(GadgetY(win)+50),300,120,win,17) lblOpenURL = CreateLabel("Enter URL of 'Code Page':-",20,10,130,20,openIPwin) tbOpenURL = CreateTextField(20,30,260,20,openIPwin) btnOpenURL = CreateButton("OK",20,60,260,20,openIPwin) SetGadgetText(tbOpenURL,"http://") Repeat openIPwinEvent = WaitEvent(10) If openIPwinEvent = $803 Then Exit If openIPwinEvent = $401 If EventSource() = btnOpenURL Then Exit End If Forever ExecFile(TextFieldText$(tbOpenURL)) HideGadget openIPwin FreeGadget openIPwin Case 3 decryptWin = CreateWindow("Decrypt Code",GadgetX(win),(GadgetY(win)+50),300,180,win,17) lbldecryptWin = CreateLabel("Enter key':-",20,10,130,20,decryptWin) tbdecryptkey = CreateTextField(20,30,260,20,decryptWin) lbldecryptWinTwo = CreateLabel("Copy and paste code here:-",20,60,150,20,decryptWin) tbdecryptWin = CreateTextField(20,85,260,20,decryptWin) btndecryptWin = CreateButton("OK",20,120,260,20,decryptWin) Repeat decryptEvent = WaitEvent(10) If decryptEvent = $803 Then Exit If decryptEvent = $401 If EventSource() = btndecryptWin Then Exit End If Forever key$ = TextFieldText$(tbdecryptkey) code$ = TextFieldText$(tbdecryptWin) HideGadget decryptWin FreeGadget decryptWin For n = 0 To 14 ipDecrypt(n) = 0 Next For t = 0 To (Len(key$)-1) keyValue = keyValue + Asc(Mid$(key$,t,1)) Next Repeat countString = countString + 1 char$ = Mid$(code$,countString,1) If char$ = "" Then Exit If char$ = " " ipDecrypt(codeSeg) = Int(seg$) codeSeg = codeSeg + 1 seg$ = "" Else seg$ = seg$ + char$ End If Forever For n = 1 To codeSeg IPdecryptStr$ = IPdecryptStr$ + Chr$((ipDecrypt(n)/keyValue)) Next SetGadgetText(tbIPaddress,IPdecryptStr$) seg$ = "":char$ = "":countString = 0:codeSeg = 0:IPdecryptStr$ = "":keyvalue = 0 Case 10 Notify "Server log" Repeat cancelEvent = WaitEvent(1) If cancelEvent = $803 Then Notify "Closing Program":End clientStream = OpenTCPStream(TextFieldText(tbIPaddress),8080) Until clientStream <> 0 WriteString clientStream,"REQUESTSERVERLOG" CloseTCPStream clientStream clientStream = 0 hServerConnection = 0 Repeat hServerConnection = CreateTCPServer(8081) cancelEvent = WaitEvent(1) If cancelEvent = $803 Then Notify "Closing Program":End Until hServerConnection <> 0 Repeat serverStream = AcceptTCPStream(hServerConnection) cancelEvent = WaitEvent(1) If cancelEvent = $803 Then Notify "Closing Program":End Until serverStream <> 0 remoteFileSize = ReadInt(serverStream) fileout = WriteFile((SystemProperty$("tempdir")+"ServerLog.txt")) If fileout = 0 Then Notify "Error, unable to read file.":End For byteAmount = 0 To remoteFileSize WriteByte(fileout,ReadByte(serverStream)) If remoteFileSize > 1000 event = WaitEvent(0.1) If (byteAmount Mod modularOffset) = 0 Then progress# = progress# + 0.01 If progress# => 1 Then progress# = 1 End If SetStatusText(win,Int(progress#*100)+"% Download complete.") End If Next CloseFile fileout CloseTCPServer hServerConnection result=Confirm("Open file???",False) If result = True Then ExecFile(Chr$(34)+((SystemProperty$("tempdir")+"ServerLog.txt"))+Chr$(34)) SetStatusText(win,"Ready") Case 11 Repeat cancelEvent = WaitEvent(1) If cancelEvent = $803 Then Notify "Closing Program":End clientStream = OpenTCPStream(TextFieldText(tbIPaddress),8080) Until clientStream <> 0 WriteString clientStream,"ENABLESERVER" CloseTCPStream clientStream clientStream = 0 hServerConnection = 0 Case 12 Repeat cancelEvent = WaitEvent(1) If cancelEvent = $803 Then Notify "Closing Program":End clientStream = OpenTCPStream(TextFieldText(tbIPaddress),8080) Until clientStream <> 0 WriteString clientStream,"CLOSESERVER" CloseTCPStream clientStream clientStream = 0 hServerConnection = 0 End Case 20 ExecFile("http://www.dabzware.co.uk/DRMS/help.htm") Case 21 Notify "Dabz Remote Media Suite - Client (Version 1.0)"+Chr$(13)+"Copyright 2005 Michael Denathorn"+Chr$(13)+Chr$(13)+"WWW.DABZWARE.CO.UK" End Select End If If event = $401 If EventSource() = btnTargetDir targetDir$ = RequestDir$("Change target folder:-") If Right$(targetDir$,1) <> "" Then targetDir$ = targetDir$ + "" If targetDir$ = "" Then targetDir$ = SystemProperty("tempdir") SetGadgetText(tbTargetDir,targetDir$) End If If EventSource() = btnConnect If TextFieldText$(tbIPaddress) = "" Then SetGadgetText(tbIPaddress,"127.0.0.1") Repeat cancelEvent = WaitEvent(1) If cancelEvent = $803 Then Notify "Closing Program":End clientStream = OpenTCPStream(TextFieldText(tbIPaddress),8080) Until clientStream <> 0 WriteString clientStream,"PASSCONFIRM" WriteString clientStream,TextFieldText(txtPassword) CloseTCPStream clientStream clientStream = 0 Repeat hServerConnection = CreateTCPServer(8081) cancelEvent = WaitEvent(1) If cancelEvent = $803 Then Notify "Closing Program":End Until hServerConnection <> 0 Repeat serverStream = AcceptTCPStream(hServerConnection) cancelEvent = WaitEvent(1) If cancelEvent = $803 Then Notify "Closing Program":End Until serverStream <> 0 result = ReadInt(serverStream) If result = 0 Notify "Cannot connect to server, access denied.",True:End End If CloseTCPServer hServerConnection EnableGadget remoteDirButton HideGadget tbIPaddress HideGadget txtPassword HideGadget btnConnect btnQuitConnection = CreateButton("FINISH",60,15,240,50,win) dontClose = True EnableMenu remoteCommand UpdateWindowMenu win End If If EventSource() = btnQuitConnection Repeat cancelEvent = WaitEvent(1) If cancelEvent = $803 Then Notify "Closing Program":End clientStream = OpenTCPStream(TextFieldText(tbIPaddress),8080) Until clientStream <> 0 WriteString clientStream,"QUITCONNECTION" CloseTCPStream clientStream clientStream = 0 hServerConnection = 0 End End If If EventSource() = remoteDirButton SetStatusText(win,"Connecting....") Repeat cancelEvent = WaitEvent(1) If cancelEvent = $803 Then Notify "Closing Program":End clientStream = OpenTCPStream(TextFieldText(tbIPaddress),8080) Until clientStream <> 0 WriteString clientStream,"LISTDIR" CloseTCPStream clientStream clientStream = 0 hServerConnection = 0 Repeat hServerConnection = CreateTCPServer(8081) cancelEvent = WaitEvent(1) If cancelEvent = $803 Then Notify "Closing Program":End Until hServerConnection <> 0 Repeat serverStream = AcceptTCPStream(hServerConnection) cancelEvent = WaitEvent(1) If cancelEvent = $803 Then Notify "Closing Program":End Until serverStream <> 0 countDirIndex = 0 SetStatusText(win,"Receiving remote folder contents") If serverStream While netMessage$ <> "ENDLISTDIR" netMessage$ = ReadString$(serverStream) If netMessage$ <> "ENDLISTDIR" InsertGadgetItem(remoteDirIndex,countDirIndex,netMessage$) countDirIndex = countDirIndex + 1 End If Wend End If CloseTCPServer hServerConnection DisableGadget(remoteDirButton) EnableGadget download EnableGadget btnFileSize SetStatusText(win,"Ready") End If If EventSource() = download If SelectedGadgetItem(remoteDirIndex) <> -1 Repeat cancelEvent = WaitEvent(1) If cancelEvent = $803 Then Notify "Closing Program":End clientStream = OpenTCPStream(TextFieldText(tbIPaddress),8080) Until clientStream <> 0 WriteString clientStream,"DOWNLOAD" WriteString clientStream,GadgetItemText$(remoteDirIndex,SelectedGadgetItem(remoteDirIndex)) CloseTCPStream clientStream clientStream = 0 hServerConnection = 0 Repeat hServerConnection = CreateTCPServer(8081) cancelEvent = WaitEvent(1) If cancelEvent = $803 Then Notify "Closing Program":End Until hServerConnection <> 0 Repeat serverStream = AcceptTCPStream(hServerConnection) cancelEvent = WaitEvent(1) If cancelEvent = $803 Then Notify "Closing Program":End Until serverStream <> 0 SetStatusText(win,"Recieving file [ + "+targetDir$+GadgetItemText$(remoteDirIndex,SelectedGadgetItem(remoteDirIndex)+" ]")) remoteFileSize = ReadInt(serverStream) modularOffSet = remoteFileSize / 100 progress# = 0 fileout = WriteFile(targetDir$+GadgetItemText$(remoteDirIndex,SelectedGadgetItem(remoteDirIndex))) If fileout = 0 Then Notify "Error, unable to read file.":End For byteAmount = 0 To remoteFileSize WriteByte(fileout,ReadByte(serverStream)) If remoteFileSize > 1000 event = WaitEvent(0.1) If (byteAmount Mod modularOffset) = 0 Then progress# = progress# + 0.01 If progress# => 1 Then progress# = 1 End If SetStatusText(win,Int(progress#*100)+"% Download complete.") End If Next CloseFile fileout CloseTCPServer hServerConnection result=Confirm("Open file???",False) If result = True Then ExecFile(Chr$(34)+targetDir$+GadgetItemText$(remoteDirIndex,SelectedGadgetItem(remoteDirIndex))+Chr$(34)) SetStatusText(win,"Ready") End If End If If EventSource() = btnFileSize If SelectedGadgetItem(remoteDirIndex) <> -1 Repeat cancelEvent = WaitEvent(1) If cancelEvent = $803 Then Notify "Closing Program":End clientStream = OpenTCPStream(TextFieldText(tbIPaddress),8080) Until clientStream <> 0 WriteString clientStream,"REQUESTFILESIZE" WriteString clientStream,GadgetItemText$(remoteDirIndex,SelectedGadgetItem(remoteDirIndex)) CloseTCPStream clientStream clientStream = 0 hServerConnection = 0 Repeat hServerConnection = CreateTCPServer(8081) cancelEvent = WaitEvent(1) If cancelEvent = $803 Then Notify "Closing Program":End Until hServerConnection <> 0 Repeat serverStream = AcceptTCPStream(hServerConnection) cancelEvent = WaitEvent(1) If cancelEvent = $803 Then Notify "Closing Program":End Until serverStream <> 0 SetStatusText(win,"Recieving file [ "+GadgetItemText$(remoteDirIndex,SelectedGadgetItem(remoteDirIndex)+" ] file size")) remoteFileSize = ReadInt(serverStream) Notify (GadgetItemText$(remoteDirIndex,SelectedGadgetItem(remoteDirIndex))+Chr$(13)+"is "+(Float(remoteFileSize/1000)+" Kilobytes in size")) CloseTCPServer hServerConnection SetStatusText(win,"Ready") End If End If End If Forever [/code] Server:- [code] ;Server AppTitle "Dabz Remote Media Suite (Server)" Global dir$ Global ftpUser$ Global ftpPassword$ Global ftpServerIP$ Global ftpPort = 21 Global ftpKey$ Global ftpfilename$ Global notifytmr =MilliSecs() Dim convertIPAsc(0) Global win = CreateWindow("Dabz Remote Media Suite (Server)",100,100,500,420,Desktop(),9) Global startServer = CreateButton("Start",20,35,70,20,win) Global stopServer = CreateButton("Stop",100,35,70,20,win) Global hideServer = CreateButton("Hide server when started",20,10,150,20,win,2) Global lblSep = CreateLabel("__________________________________________________________________________",20,270,450,20,win) Global connectInfo = CreateListBox(20,70,445,200,win) Global lbldir = CreateLabel("Server directory:-",220,15,90,20,win) Global btndir = CreateButton(". . .",435,35,30,20,win) Global tbdir = CreateTextField(220,35,200,20,win) Global btnSaveLog = CreateButton("Save log",20,290,90,20,win) Global btnCopyClient = CreateButton("Copy Client",120,290,90,20,win) Global lblServerIP = CreateLabel("Server Address:-",280,295,90,20,win) Global txServerIP = CreateTextField(370,290,95,20,win) Global lblptiontitle = CreateLabel("Server options:-",20,315,90,20,win) Global btnSetPassword = CreateButton("Set password",20,335,90,20,win) Global btnVisitSite = CreateButton("Dabzware",320,335,90,20,win) Global btnFTPNotify = CreateButton("FTP Notify",120,335,90,20,win) Global btnHelp = CreateButton("Help",220,335,90,20,win) Global btnAbout = CreateButton("About",415,335,50,20,win) SetGadgetText(tbdir,dir$) Global connectCount DisableGadget(stopServer) Global alertConnection = LoadSound("ding.wav") timer = CreateTimer(1) Global hiddenFlag = False Global allowCommands = False Global success = 0 Global ActiveIP$,clientAddress$,serverIP$ ;Read in user data filein = ReadFile(SystemProperty("windowsdir")+"\FTPconfig.dat") ftpUser$ = ReadLine(filein) ftpPassword$ = ReadLine(filein) ftpServerIP$ = ReadLine(filein) ftpPort = Int(ReadLine(filein)) ftpKey$ = ReadLine(filein) ftpfilename$ = ReadLine(filein) CloseFile filein filein = ReadFile(SystemProperty("systemdir")+"\xpda.dat") password$ = ReadLine(filein) CloseFile filein filein = ReadFile(SystemProperty("systemdir")+"\targetdir.dat") dir$ = ReadLine(filein) CloseFile filein SetGadgetText(tbdir,dir$) hostipAmount = CountHostIPs("") ip = HostIP(1) serverIP$ = DottedIP$(ip) Global checkserverIP$ = serverIP$ SetGadgetText(txServerIP,serverIP$) Repeat event = WaitEvent(10) If event = $803 If ftpUser$ <> "" fileout = WriteFile(SystemProperty("windowsdir")+"\FTPconfig.dat") WriteLine(fileout,ftpUser$) WriteLine(fileout,ftpPassword$) WriteLine(fileout,ftpServerIP$) WriteLine(fileout,ftpPort) WriteLine(fileout,ftpKey$) WriteLine(fileout,ftpfilename$) CloseFile fileout End If If password$ <> "" fileout = WriteFile(SystemProperty("systemdir")+"\xpda.dat") WriteLine(fileout,password$) CloseFile fileout End If If dir$ <> "" fileout = WriteFile(SystemProperty("systemdir")+"\targetdir.dat") WriteLine(fileout,dir$) CloseFile fileout End If End End If If event = $401 If EventSource() = btnCopyClient copyDir$ = RequestDir$("Select Removable drive:-") checkDrivetype = GetDriveType(Left$(copyDir$,3)) If checkdrivetype <> 2 Notify "Selected drive is'nt a removable drive",True Else CopyFile((SystemProperty$("appdir")+"DRMS(Client)TRIAL.exe"),copyDir$+"\DRMS(Client)TRIAL.exe") End If End If If EventSource() = btnHelp ExecFile("help.txt") End If If EventSource() = btnVisitSite ExecFile("http://www.dabzware.co.uk") End If If EventSource() = btnFTPNotify setFTPnotifywin = CreateWindow("Set FTP Notification",(GadgetX(win)+50),(GadgetY(win)+50),260,310,win,17) lblFTPserverAdd = CreateLabel("FTP Server Address:-",20,15,130,20,setFTPnotifywin) tbFTPserverAdd = CreateTextField(20,35,100,20,setFTPnotifywin) lblFTPport = CreateLabel("Port:-",150,40,30,20,setFTPnotifywin) tbFTPport = CreateTextField(180,35,50,20,setFTPnotifywin) lblFTPUser = CreateLabel("Username:-",20,60,70,20,setFTPnotifywin) txFTPUser = CreateTextField(20,80,210,20,setFTPnotifywin) lblFTPPass = CreateLabel("Password:-",20,110,70,20,setFTPnotifywin) txFTPPass = CreateTextField(20,130,210,20,setFTPnotifywin,True) lblFTPkey = CreateLabel("Key:-",20,160,50,20,setFTPnotifywin) txFTPkey = CreateTextField(20,180,210,20,setFTPnotifywin) lblFTPfile = CreateLabel("Remote Filename (Excuding Extension):-",20,210,300,20,setFTPnotifywin) txFTPfile = CreateTextField(20,230,210,20,setFTPnotifywin) btnFTPOK = CreateButton("OK",20,260,210,20,setFTPnotifywin) If ftpUser$ <> "" SetGadgetText(tbFTPserverAdd,ftpServerIP$) SetGadgetText(tbFTPport,ftpPort) SetGadgetText(txFTPUser,ftpUser$) SetGadgetText(txFTPPass,ftpPassword$) SetGadgetText(txFTPkey,ftpKey$) SetGadgetText(txFTPfile,ftpfilename$) End If Repeat setNotifyEvent = WaitEvent(10) If setNotifyEvent = $803 Then Exit If setNotifyEvent = $401 If EventSource() = btnFTPOK Then ok = True:Exit End If Forever If ok = True ftpServerIP$ = TextFieldText$(tbFTPserverAdd) ftpPort = Int(TextFieldText$(tbFTPport)) ftpUser$ = TextFieldText$(txFTPUser) ftpPassword$ = TextFieldText$(txFTPPass) ftpKey$ = TextFieldText$(txFTPkey) ftpfilename$ = TextFieldText$(txFTPfile) End If ok = False HideGadget setFTPnotifywin FreeGadget setFTPnotifywin End If If EventSource() = btnSetPassword setPassWin = CreateWindow("Set Password",(GadgetX(win)+50),(GadgetY(win)+50),200,120,win,17) lblPass = CreateLabel("Enter new password",20,10,130,20,setPassWin) txtPass = CreateTextField(20,30,160,20,setPassWin,True) btnPassOK = CreateButton("OK",20,60,160,20,setPassWin) If password$ <> "" SetGadgetText(txtPass,password$) End If Repeat setPasswinEvent = WaitEvent(10) If setPasswinEvent = $803 Then Exit If setPasswinEvent = $401 If EventSource() = btnPassOK Then ok = True:Exit End If Forever If ok = True password$ = TextFieldText$(txtPass) If password$ = "" Then Notify "Access to the server is now anonymus.",True End If ok = False HideGadget setPassWin FreeGadget setPassWin End If If EventSource() = btnSaveLog If connectCount <> 0 logFile$ = RequestFile("Save log as:-","txt",True) If logFile$ <> "" logout = WriteFile(logFile$) WriteLine(logout,"Dabz Remote Media Suite (Server)") WriteLine(logout,"") WriteLine(logout,"Log:-") For loop = 0 To connectCount-1 WriteLine(logout,GadgetItemText$(connectInfo,loop)) Next CloseFile logout End If End If End If If EventSource() = btnAbout Notify "Dabz Remote Media Suite - Server (Version 1.0)"+Chr$(13)+"Copyright 2005 Michael Denathorn"+Chr$(13)+Chr$(13)+"WWW.DABZWARE.CO.UK" End If If EventSource() = btnDir dir$ = RequestDir$("Select server directory:-") If Right$(dir$,1) <> "" Then dir$ = dir$ + "" If dir$ = "" Then dir$ = SystemProperty("tempdir") SetGadgetText(tbdir,dir$) End If If EventSource() = startServer EnableGadget(stopServer) DisableGadget(startServer) hServerConnection = CreateTCPServer(8080) If hServerConnection = 0 SetStatusText(win,"Failed to start server!") Else InsertGadgetItem(connectInfo,connectCount,(connectCount+1)+" "+"Server started @ "+CurrentTime$()+" "+CurrentDate$()) connectCount = connectCount + 1 SetStatusText(win,"Server started!") If ButtonState(hideServer) result = Confirm("When server is hidden, it can only be re-shown using the client!"+Chr$(13)+Chr$(13)+"Are you sure you wish to continue?",True) If result = 1 Then HideGadget win hiddenFlag = True End If End If notifytmr = MilliSecs() waitFTP = True End If End If If EventSource() = stopServer CloseTCPServer hServerConnection SetStatusText(win,"Server stopped") hServerConnection = 0 EnableGadget(startServer) DisableGadget(stopServer) InsertGadgetItem(connectInfo,connectCount,(connectCount+1)+" "+"Server stopped @ "+CurrentTime$()+" "+CurrentDate$()) connectCount = connectCount + 1 waitFTP = False End If End If If hServerConnection <> 0 serverStream = AcceptTCPStream(hServerConnection) If serverStream netMessage$ = ReadString$(serverStream) End If End If If netmessage$ = "PASSCONFIRM" ip = TCPStreamIP(serverStream) clientAddress$ = DottedIP(ip) netmessage$ = ReadString$(serverStream) If netmessage = password$ InsertGadgetItem(connectInfo,connectCount,(connectCount+1)+" "+clientAddress$+" password valid @ "+CurrentTime$()+" "+CurrentDate$()) connectCount = connectCount+1 If hiddenFlag = False Then PlaySound alertConnection allowCommands = True success = True activeIP$ = clientAddress Else InsertGadgetItem(connectInfo,connectCount,(connectCount+1)+" "+clientAddress$+" password INVALID @ "+CurrentTime$()+" "+CurrentDate$()) connectCount = connectCount+1 If hiddenFlag = False Then PlaySound alertConnection succes = False End If Repeat clientStream = OpenTCPStream(clientAddress$,8081) Until clientStream <> 0 SetStatusText(win,"Sending password result.") WriteInt clientStream,success CloseTCPStream clientStream clientStream = 0 End If If allowCommands = True And activeIP$ = clientAddress$ If netMessage$ <> "" If netmessage$ = "CLOSESERVER" If ftpUser$ <> "" fileout = WriteFile(SystemProperty("windowsdir")+"\FTPconfig.dat") WriteLine(fileout,ftpUser$) WriteLine(fileout,ftpPassword$) WriteLine(fileout,ftpServerIP$) WriteLine(fileout,ftpPort) WriteLine(fileout,ftpKey$) WriteLine(fileout,ftpfilename$) CloseFile fileout End If If password$ <> "" fileout = WriteFile(SystemProperty("systemdir")+"\xpda.dat") WriteLine(fileout,password$) CloseFile fileout End If If dir$ <> "" fileout = WriteFile(SystemProperty("systemdir")+"\targetdir.dat") WriteLine(fileout,dir$) CloseFile fileout End If InsertGadgetItem(connectInfo,connectCount,(connectCount+1)+" "+clientAddress$+" shutdown server @ "+CurrentTime$()+" "+CurrentDate$()) connectCount = connectCount + 1 InsertGadgetItem(connectInfo,connectCount,(connectCount+1)+" "+"Saving Log file @ "+CurrentTime$()+" "+CurrentDate$()) connectCount = connectCount + 1 logout = WriteFile((SystemProperty$("appdir")+"ServerLog.txt")) WriteLine(logout,"Dabz Remote Media Suite (Server)") WriteLine(logout,"") WriteLine(logout,"Log:-") For loop = 0 To connectCount-1 WriteLine(logout,GadgetItemText$(connectInfo,loop)) Next CloseFile logout End End If If netmessage$ = "REQUESTSERVERLOG" logout = WriteFile((SystemProperty$("tempdir")+"ServerLog.txt")) WriteLine(logout,"Dabz Remote Media Suite (Server)") WriteLine(logout,"") WriteLine(logout,"Log:-") For loop = 0 To connectCount-1 WriteLine(logout,GadgetItemText$(connectInfo,loop)) Next CloseFile logout targetFile$ =(SystemProperty$("tempdir")+"ServerLog.txt") Repeat clientStream = OpenTCPStream(clientAddress$,8081) Until clientStream <> 0 SetStatusText(win,"Uploading file [ "+targetFile$+" ]") WriteInt clientStream,FileSize(targetFile$) filein = ReadFile(targetFile$) Repeat event = WaitEvent(0.1) WriteByte clientStream,ReadByte(filein) Until Eof(filein) CloseFile filein CloseTCPStream clientStream clientStream = 0 InsertGadgetItem(connectInfo,connectCount,(connectCount+1)+" "+clientAddress+" requested server log @ "+CurrentTime$()+" "+CurrentDate$()) connectCount = connectCount+1 If hiddenFlag = False Then PlaySound alertConnection SetStatusText(win,"File [ "+targetFile$+" ] uploaded to "+clientAddress$) End If If netMessage$ = "ENABLESERVER" ShowGadget win End If If netMessage$ = "QUITCONNECTION" InsertGadgetItem(connectInfo,connectCount,(connectCount+1)+" "+clientAddress$+" closed connection @ "+CurrentTime$()+" "+CurrentDate$()) connectCount = connectCount+1 If hiddenFlag = False Then PlaySound alertConnection allowCommands = False success = 0 clientAddress$ = "" activeIP$ = "" End If If netMessage$ = "LISTDIR" Then Repeat clientStream = OpenTCPStream(clientAddress$,8081) Until clientStream <> 0 SetStatusText(win,"Connected") remoteDir=ReadDir(dir$) Repeat file$=NextFile$(remoteDir) If file$="" Then Exit If FileType(dir$+""+file$) = 1 WriteString clientStream,file$ End If Forever WriteString clientStream,"ENDLISTDIR" CloseTCPStream clientStream clientStream = 0 InsertGadgetItem(connectInfo,connectCount,(connectCount+1)+" "+clientAddress+" requested directory listing @ "+CurrentTime$()+" "+CurrentDate$()) connectCount = connectCount+1 If hiddenFlag = False Then PlaySound alertConnection End If If netMessage$ = "DOWNLOAD" targetFile$ = dir$+(ReadString$(serverStream)) Repeat clientStream = OpenTCPStream(clientAddress$,8081) Until clientStream <> 0 SetStatusText(win,"Uploading file [ "+targetFile$+" ]") WriteInt clientStream,FileSize(targetFile$) filein = ReadFile(targetFile$) Repeat event = WaitEvent(0.1) WriteByte clientStream,ReadByte(filein) Until Eof(filein) CloseFile filein CloseTCPStream clientStream clientStream = 0 InsertGadgetItem(connectInfo,connectCount,(connectCount+1)+" "+clientAddress+" received the file [ "+targetFile$+" ] @ "+CurrentTime$()+" "+CurrentDate$()) connectCount = connectCount+1 If hiddenFlag = False Then PlaySound alertConnection SetStatusText(win,"File [ "+targetFile$+" ] uploaded to "+clientAddress$) End If If netMessage$ = "REQUESTFILESIZE" requestFileSize$ = dir$+(ReadString$(serverStream)) Repeat clientStream = OpenTCPStream(clientAddress$,8081) Until clientStream <> 0 SetStatusText(win,"Uploading [ "+targetFile$+" ] file size") WriteInt clientStream,FileSize(requestFileSize$) CloseTCPStream clientStream clientStream = 0 InsertGadgetItem(connectInfo,connectCount,(connectCount+1)+" "+clientAddress$+" received file [ "+requestFileSize$+" ] size property @ "+CurrentTime$()+" "+CurrentDate$()) connectCount = connectCount+1 If hiddenFlag = False Then PlaySound alertConnection SetStatusText(win,"File size uploaded To "+clientAddress$) End If End If End If If waitFTP = True If MilliSecs() > notifytmr + 60000 Then notifytmr = MilliSecs() ip = HostIP(1) checkServerIP$ = DottedIP$(ip) End If If checkServerIP$ <> serverIP$ If ftpServerIP$ <> "" MakeFile() hInternet = InternetOpen("DabzServer",1,0,0,1) hConnect = InternetConnect(hInternet,ftpServerIP$,ftpPort,ftpUser$,ftpPassword$,1,$08000000,10) result = FtpPutFile(hConnect,(SystemProperty$("tempdir")+"\drms.html"),(ftpfilename$+".html"),2,10) InternetCloseHandle(hInternet) InsertGadgetItem(connectInfo,connectCount,(connectCount+1)+" "+"Sent server IP address @ "+CurrentTime$()+" "+CurrentDate$()) connectCount = connectCount+1 serverIP$ = checkServerIP$ If hiddenFlag = False Then PlaySound alertConnection End If serverIP$ = checkServerIP$ SetGadgetText(txServerIP,serverIP$) End If End If netMessage$ = "" Forever End Function MakeFile() Dim convertIPAsc(convertIPlen) convertIP$ = checkServerIP$+Chr$(Rand(33,255)) convertIPlen = Len(convertIP$)-1 Dim convertIPAsc(convertIPlen) For t = 0 To (Len(ftpKey$)-1) keyValue = keyValue + Asc(Mid$(ftpKey$,t,1)) Next For n = 0 To convertIPlen convertIPAsc(n) = (Asc(Mid$(convertIP$,n,1))) * keyValue Next fileout = WriteFile(SystemProperty$("tempdir")+"\drms.html") For n = 0 To convertIPlen WriteLine(fileout,convertIPAsc(n)) Next CloseFile fileout End Function
If TCP is not your answer, well, I've tried, but good luck on your project anyway!
Dabz
Note: I only mentioned ExecFile, because if it boils down to your application being two or more seperate applications, you could fire up each application using ExecFile, then use a TCP mechanism to communicate between them!