#include "FiveWin.ch"
#define HKEY_LOCAL_MACHINE 2147483650
STATIC oWnd, oActivex
FUNCTION Main()
LOCAL oBar
/*
http://fivewin.com.br/index.php?/topic/27339-problema-na-busca-do-cnpj-site-da-receita/
http://forums.fivetechsupport.com/viewtopic.php?f=6&t=34901
*/
INTER_APP_WEB_CONFIG("TESTE2.exe",11001)
DEFINE WINDOW oWnd TITLE "Google Action"
DEFINE BUTTONBAR oBar _3D OF oWnd
DEFINE BUTTON OF oBar ACTION Receita( oWnd )
SET MESSAGE OF oWnd TO "Google Action" NOINSET CLOCK DATE KEYBOARD
ACTIVATE WINDOW oWnd
RETURN NIL
Function Receita( oWnd )
Local cPortal
local cEvents := ""
If !IsInternet()
Msgalert("Não conectado a internet.", "Aviso!")
Return nil
Endif
MsgWait( "CONECTANDO AO PORTAL DA RECEITA ", ;
"AGUARDE... ", 3.0 )
DEFINE WINDOW oWnd FROM 0,0 TO 600,800 PIXEL TITLE "Receita.GOV"
// oActiveX = TActiveX():New( oWnd, "Shell.Explorer.2" ) // nao funciona no IE
// nao funciona no IE
@ 0, 0 ACTIVEX oActiveX PROGID "Shell.Explorer.2" OF oWnd
oWnd:oClient = oActiveX
// oActiveX:GoHome()
oActivex:Silent := .T.
oActiveX:FullScreen := .T.
oActiveX:Visible := .T.
oActiveX:ToolBar := .T.
oActiveX:StatusBar := .T.
oActiveX:MenuBar := .T.
oActivex:SetFocus()
oActiveX:Do( "Navigate2", "https://www.receita.fazenda.gov.br/PessoaJuridica/CNPJ/cnpjreva/Cnpjreva_Solicitacao2.asp" )
oActiveX:bOnEvent = { | event, aParams, pParams | cEvents += EventInfo( event, aParams, pParams, oActiveX ) }
ACTIVATE WINDOW oWnd CENTER ;
VALID ( MemoEdit( cEvents ), .t. )
// VALID( oActiveX:End() )
// Com ShellExecute funciona perfeito no chrome.
/*
cPortal := "https://www.receita.fazenda.gov.br/PessoaJuridica/CNPJ/cnpjreva/Cnpjreva_Solicitacao2.asp"
If !IsInternet()
Msgalert("Não conectado a internet.", "Aviso!")
Return nil
Endif
MsgWait( "CONECTANDO AO PORTAL DA SEFAZ...", ;
"AGUARDE... ", 3.0 )
// Executa o navegador padrao... Google Chrome nao gosto do IE.
ShellExecute( GetActiveWindow(), "open", cPortal,,,9 )
*/
Return nil
function EventInfo( event, aParams, pParams, oActiveX )
local cMsg := "Evento: " + cValToChar( event ) + CRLF
local n
cMsg += "Params: " + CRLF
for n = 1 to Len( aParams )
cMsg += cValToChar( aParams[ n ] ) + CRLF
next
if event == "BeforeNavigate2"
// MsgInfo( aParams[ 2 ] )
// SetEventParam( pParams, 7, .t. ) // Comment this to allow navigation
endif
return cMsg + CRLF
/*
Parametrize seu programa com a versão do seu navegador atual.
Ex: se seu navegador for iexplorer 11 coloque assim
INTER_APP_WEB_CONFIG("SeuPrograma.exe",11001)
*/
FUNCTION INTER_APP_WEB_CONFIG(f_cNameProg,f_nVersion_IE)
Local oRegKey, cRegProgGet, lDeleteKey := .f.
Default f_nVersion_IE := 11001
if IsWow64()
oRegKey := TReg32():New( HKEY_LOCAL_MACHINE,;
"SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION" )
oRegKey:Set(f_cNameProg,f_nVersion_IE,4)
oRegKey:Close()
oRegKey := TReg32():New( HKEY_LOCAL_MACHINE,;
"SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_AJAX_CONNECTIONEVENTS" )
oRegKey:Set(f_cNameProg,0,4) // Padrão 0
oRegKey:Close()
oRegKey := TReg32():New( HKEY_LOCAL_MACHINE,;
"SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_ZONE_ELEVATION" )
oRegKey:Set(f_cNameProg,0,4) // Padrão 1
oRegKey:Close()
oRegKey := TReg32():New( HKEY_LOCAL_MACHINE,;
"SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_READ_ZONE_STRINGS_FROM_REGISTRY" )
oRegKey:Set(f_cNameProg,1,4) // Padrão 0
oRegKey:Close()
oRegKey := TReg32():New( HKEY_LOCAL_MACHINE,;
"SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BEHAVIORS" )
oRegKey:Set(f_cNameProg,1,4)
oRegKey:Close()
oRegKey := TReg32():New( HKEY_LOCAL_MACHINE,;
"SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_ENABLE_WEB_CONTROL_VISUALS" )
oRegKey:Set(f_cNameProg,1,4)
oRegKey:Close()
oRegKey := TReg32():New( HKEY_LOCAL_MACHINE,;
"SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_SHOW_APP_PROTOCOL_WARN_DIALOG" )
oRegKey:Set(f_cNameProg,1,4) // Padrao 0
oRegKey:Close()
oRegKey := TReg32():New( HKEY_LOCAL_MACHINE,;
"SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_GPU_RENDERING" )
oRegKey:Set(f_cNameProg,1,4) // Padrao 0
oRegKey:Close()
oRegKey := TReg32():New( HKEY_LOCAL_MACHINE,;
"SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_NINPUT_LEGACYMODE" )
oRegKey:Set(f_cNameProg,0,4) // Padrao 1
oRegKey:Close()
Else
oRegKey := TReg32():New( HKEY_LOCAL_MACHINE,;
"Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION" )
oRegKey:Set(f_cNameProg,f_nVersion_IE,4)
oRegKey:Close()
oRegKey := TReg32():New( HKEY_LOCAL_MACHINE,;
"SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BEHAVIORS" )
cRegProgGet := oRegKey:GetBinary(f_cNameProg)
//? cRegProgGet
If Empty(cRegProgGet)
oRegKey:Set(f_cNameProg,1,4)
EndIf
oRegKey:Close()
oRegKey := TReg32():New( HKEY_LOCAL_MACHINE,;
"SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_ENABLE_WEB_CONTROL_VISUALS" )
oRegKey:Set(f_cNameProg,1,4)
oRegKey:Close()
EndIf
RETURN NIL