Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Code Snippets / wininet.dll - connecting to internet and FTP

Author
Message
Bored of the Rings
User Banned
Posted: 18th Mar 2022 06:21 Edited at: 29th Mar 2022 07:51


Attached is the updated FTP dll and fixed GET FTP DIR$(). Below is example code that connects to an anonymous FTP site and displays the current ftp directory and lists the files under that directory:



editor keywords/help files added to dll talk post.
Professional Programmer, languages: SAS, C++, SQL, PL-SQL, DBPro, Purebasic, JavaScript, others

Attachments

Login to view attachments
Bored of the Rings
User Banned
Posted: 19th Mar 2022 08:05 Edited at: 19th Mar 2022 19:48
updated to connect to my website that contains files for Autowelder and list file content with attributes, this is a test only for DBPro, it's much more easier believe it or not) to do it in Visual Studio, just want to show that anything is possible in DBPro, it helps to understand some structures in VS such as the WIN32_FIND_FILES, MAX_PATH, FILETIME and loads more etc:





Obviously, I would put code into functions etc, this is just for demo purposes. maybe later will tidy up and add the functions.
I've used memblock here but could use Banks or ALLOC. Just need a pointer to the find_files data structure.

recursion would be good here also, remember if you want to "find first file" then you need to close the handle first and then change directory if you need to and then do a "find first file " then "find next file". This is basically the same as the DBPro commands FIND FIRST and FIND NEXT, it's just "stolen" from the wininet.dll
Professional Programmer, languages: SAS, C++, SQL, PL-SQL, DBPro, Purebasic, JavaScript, others
Bored of the Rings
User Banned
Posted: 19th Mar 2022 18:23 Edited at: 19th Mar 2022 19:47
another update, this time converting a date from FILETIME format to SYSTEMTIME format, see example code which I will be expnading over the coming few days.



Again to get a pointer to the SYSTEMTIME format I have created a 2nd memblock , grabbed the pointer and the call to the "FileTimeToSystemTime" function ("kernel32.dll"), populates the 2nd memblock and peek'ing it returns the various date/time values
Professional Programmer, languages: SAS, C++, SQL, PL-SQL, DBPro, Purebasic, JavaScript, others
Bored of the Rings
User Banned
Posted: 20th Mar 2022 07:44 Edited at: 20th Mar 2022 07:50
the code below, obtains the current FTP directory, the DBP command GET FTP DIR$() doesn't work, this does:
you can use the "GETLASTERROR" function from the kernel32.dll if you want to get the error code produced from any function call that returns 0 (FALSE).
Notice I have replaced memblock with ALLOC ZEROED to reduce number of code lines and is more professional / efficient. I use FREE command to delete the allocated memory at the end.



Actually, I will probably fix some DBPro commands that don't work in the DBPRO github source code. Starting with this one.
Professional Programmer, languages: SAS, C++, SQL, PL-SQL, DBPro, Purebasic, JavaScript, others
Bored of the Rings
User Banned
Posted: 21st Mar 2022 05:29 Edited at: 21st Mar 2022 05:32
Now, if like me you have the google drive ftp adaptor installed and working, you don't need filezilla to look at your files, you can connect and view your files using above code, but with following credentials as per github google drive adaptor instructions:

sServerName as string = "localhost"
nServerPort as integer = 1821
sUsername as string = "user"
sPassword as string = "user"

and then connect using:
checkconnected = call dll (wininet,"InternetCheckConnectionA","http://google.com",1,0)

https://github.com/andresoviedo/google-drive-ftp-adapter

so if you want to avoid having to login into your gdrive account and being asked every time to verify using your mobile phone, go to the github link first and follow the instructions (there is also a youtube video on how to do same).
link to you tube video:
https://www.youtube.com/watch?v=lXvfhYRPRX0
Professional Programmer, languages: SAS, C++, SQL, PL-SQL, DBPro, Purebasic, JavaScript, others
Bored of the Rings
User Banned
Posted: 22nd Mar 2022 06:30 Edited at: 22nd Mar 2022 06:38
the code now uses functions, you can use either ALLOC / MEMBLOCK (GET MEMBLOCK PTR) / BANK (GET BANK PTR) or DIM and then obtain the array pointer using GET ARRAYPTR. you need IanM Matrix1Util plugin for this.
Change the code if you want, make it better. I'm going to be updating the DBPRO source code to fix some of the commands that don't work. I've already noticed in the source code that the code is wrong for GET FTP DIR$(). This is easily fixed.
A few months back I updated the memblocks source code to allow more memblocks, If I recall I added 10,000 as a tester and compiles / works fine so far. There is so much that can be done with the source code. I've seen quite a lot of mistakes in places and/or inconsistencies, memory leaks etc.

I haven't put the dll calls to close the handles in yet, maybe you guys/girls can have a go. But I will add later date. Im off to do working day and then update DBPro code etc.

Professional Programmer, languages: SAS, C++, SQL, PL-SQL, DBPro, Purebasic, JavaScript, others
Bored of the Rings
User Banned
Posted: 23rd Mar 2022 16:13
fixed the GET FTP DIR$() in the DBPro source code, the code was originally a copy of the GetFileName function, terrible, still glad it's fixed.
If anyone wants the updated DLL , I will place it on the 1st post when it's finalised, need to double check and add some error trapping/fail safe code.
I will put this notice on the main DBPro Professional board.

Professional Programmer, languages: SAS, C++, SQL, PL-SQL, DBPro, Purebasic, JavaScript, others
Bored of the Rings
User Banned
Posted: 24th Mar 2022 06:11
updated 2nd code , just to show change to another directory , return the current directory using the fixed GET FTP DIR$ command and listing the directory.
adding the updated FTP dll to the dll boards.
Professional Programmer, languages: SAS, C++, SQL, PL-SQL, DBPro, Purebasic, JavaScript, others
Bored of the Rings
User Banned
Posted: 25th Mar 2022 10:01
adding commands to return date stamps i.e. create, access and modification datetime stamps.
Professional Programmer, languages: SAS, C++, SQL, PL-SQL, DBPro, Purebasic, JavaScript, others
Bored of the Rings
User Banned
Posted: 27th Mar 2022 06:51
the FTP datetime stamp commands are now in and working. I'm keeping the format the same as Matrix1Utils (IanM) for consistency. as my website files are unix based, there won't be any valid creation/access datetime stamps as unix doesn't keep track of them so only modification timestamps will show:

The commands are:

GET FTP FILE CREATETS$();
GET FTP FILE ACCESSTS$();
GET FTP FILE MODTS$()



Looking into other commands and updates/fixes etc. Not necessarily FTP related.
Professional Programmer, languages: SAS, C++, SQL, PL-SQL, DBPro, Purebasic, JavaScript, others
Bored of the Rings
User Banned
Posted: 27th Mar 2022 07:19
updated FTP dll with additional datetime stamp commands - just backup your old one and copy/paste in compiler / plugins ]. see 1st post @ link : https://forum.thegamecreators.com/thread/228370
Professional Programmer, languages: SAS, C++, SQL, PL-SQL, DBPro, Purebasic, JavaScript, others
Bored of the Rings
User Banned
Posted: 29th Mar 2022 07:48
small update to the ftp dll made and editor keywords / help files added. see link above.
Professional Programmer, languages: SAS, C++, SQL, PL-SQL, DBPro, Purebasic, JavaScript, others
Bored of the Rings
User Banned
Posted: 2nd Apr 2022 06:43
a few easy wininet commands until I get them into the FTP dll.

Professional Programmer, languages: SAS, C++, SQL, PL-SQL, DBPro, Purebasic, JavaScript, others

Login to post a reply

Server time is: 2024-03-04 03:04:36
Your offset time is: 2024-03-04 03:04:36