Retrieving a web page via shell.explorer

User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Davide,

>
Some of the properties I sent you this morning allows even to be changed directly inside the ActiveX control. This way you could even change the appearance of your page locally, allowing you to use your web server as a "template" for your local application (now it's time to be really excited ).
>

Thats exactly how I browse the images in my demo :-)

I modify the InnerHTML on the fly ;-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Very useful documentation links, thanks to Davide:

"Shell.Explorer" document object:
http://msdn.microsoft.com/en-us/library ... S.85).aspx

Navigate2 method:
http://msdn.microsoft.com/en-us/library ... S.85).aspx
regards, saludos

Antonio Linares
www.fivetechsoft.com
Davide
Posts: 190
Joined: Tue Mar 14, 2006 1:59 am
Location: Italy

Post by Davide »

Antonio Linares wrote: Navigate2 method:
http://msdn.microsoft.com/en-us/library ... S.85).aspx
Main problem here is how to translate a string like "user=username&password=mypwd" into a ByteArray (please see sub PackBytes() at http://support.microsoft.com/kb/167658) in order to do:

oActiveX:Do( "Navigate2", cURL, , , vPostData, "Content-Type: application/x-www-form-urlencoded"+CRLF)

Once this is solved we can post data to a script on a server (any script on the internet) and retrieve the dynamically generated page directly in the oActiveX object.

Hi,
Davide
User avatar
Patrick Mast
Posts: 244
Joined: Sat Mar 03, 2007 8:42 pm

Post by Patrick Mast »

Davide wrote:
Antonio Linares wrote: Navigate2 method:
http://msdn.microsoft.com/en-us/library ... S.85).aspx
Main problem here is how to translate a string like "user=username&password=mypwd" into a ByteArray (please see sub PackBytes() at http://support.microsoft.com/kb/167658) in order to do:

oActiveX:Do( "Navigate2", cURL, , , vPostData, "Content-Type: application/x-www-form-urlencoded"+CRLF)

Once this is solved we can post data to a script on a server (any script on the internet) and retrieve the dynamically generated page directly in the oActiveX object.

Hi,
Davide
Now we are talking! ;-)

Patrick
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Davide,

Here you have it. Lets try it :-)

I am calling CreateObject() so the OLE engine is properly initialized. Not needed once we use the ActiveX. Here it seems to work fine, at least there are no GPFs and it is returning a string.

test.prg

Code: Select all

#include "FiveWin.ch"

function Main()

   local oExplorer := CreateObject( "shell.explorer" )

   MsgInfo( GetPostData( "user=username&password=mypwd" ) )
   
return nil   

#pragma BEGINDUMP

#include <hbapi.h>
#include <windows.h>

HRESULT hb_oleVariantToItem( PHB_ITEM pItem, VARIANT * pVariant );

HB_FUNC( GETPOSTDATA )
{
   VARIANT vPostData = {0};
   LPSAFEARRAY psa;
   LPCTSTR cszPostData = hb_parc( 1 );
   UINT cElems = lstrlen( cszPostData );
   LPSTR pPostData;

   VariantInit( &vPostData );

   psa = SafeArrayCreateVector( VT_UI1, 0, cElems );
   if( ! psa )
   {
      hb_retnl( E_OUTOFMEMORY );
      return;
   }

   SafeArrayAccessData( psa, ( LPVOID * ) &pPostData );
   memcpy( pPostData, cszPostData, cElems );
   SafeArrayUnaccessData( psa );

   V_VT( &vPostData ) = VT_ARRAY | VT_UI1;
   V_ARRAY( &vPostData ) = psa;

   hb_oleVariantToItem( hb_param( -1, HB_IT_ANY ), &vPostData );
}

#pragma ENDDUMP      
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Davide, Patrick,

Got it working! :-D

wow!!!
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Patrick Mast
Posts: 244
Joined: Sat Mar 03, 2007 8:42 pm

Post by Patrick Mast »

Antonio Linares wrote:Got it working! :-D
wow!!!
This is FUN isn't it?? ;-)
Show us! ;-)

Patrick
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Patrick,

Please provide me a php from a https site, like this:

https://www.test.com/test.php // or from a subdomain, doesn't matter

and tell me what values to post, and display them from your php, and I will build the test in a moment ;-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

In example:

test.php

Code: Select all

<? echo "This is a test\n"; ?>
<? echo $HTTP_POST_VARS['first']; ?>
<? echo $HTTP_POST_VARS['last']; ?>
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Patrick,

Never mind, it is not needed. I am building the test on our secure server :-)

Just a moment...
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Patrick Mast
Posts: 244
Joined: Sat Mar 03, 2007 8:42 pm

Post by Patrick Mast »

Antonio Linares wrote:Never mind, it is not needed. I am building the test on our secure server :-)
Just a moment...
Ok! ;-)

Patrick
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

This is the code:

test.prg

Code: Select all

#include "FiveWin.ch"

function Main()

   local oWnd, oActiveX
   
   DEFINE WINDOW oWnd
   
   @ 0, 0 ACTIVEX oActiveX PROGID "Shell.Explorer" OF oWnd
   
   oWnd:oClient = oActiveX
   
   ACTIVATE WINDOW oWnd ;
      ON INIT oActiveX:Do( "Navigate2",;
                           "https://www.fivetechsoft.com/secure/english/test.php",,,;
                           GetPostData( "first=fivewin&last=FiveTech Software" ),;
                           "Content-Type: application/x-www-form-urlencoded" + CRLF )
   
return nil 
Here you can download the EXE:
http://rapidshare.com/files/142522826/test.zip.html

Besides the published GetPostData() source code, a modified Class TActiveX is required that will be included in next FWH build.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Patrick Mast
Posts: 244
Joined: Sat Mar 03, 2007 8:42 pm

Post by Patrick Mast »

Antonio,

Works just fine here! Congrats!
This opens so many posibilities! ;-)

Patrick
Davide
Posts: 190
Joined: Tue Mar 14, 2006 1:59 am
Location: Italy

Post by Davide »

Antonio,
great! now we can really communicate with the world.
I'm looking forward for the next FWH build.
Hi
Horizon
Posts: 997
Joined: Fri May 23, 2008 1:33 pm

Post by Horizon »

Antonio,

I just want to post some data to my web page, but i don't want to see any explorer screen. Can I do it your last example?

Thanks,
Regards,

Hakan ONEMLI

Harbour & VS 2019 & FWH 20.12
Post Reply