Has Purebasic upgraded the webgadget?

Just starting out? Need help? Post your questions and find answers here.
User avatar
TI-994A
Addict
Addict
Posts: 2705
Joined: Sat Feb 19, 2011 3:47 am
Location: Singapore
Contact:

Re: Has Purebasic upgraded the webgadget?

Post by TI-994A »

ts-soft wrote:The ATL.dll is installed on all windows versions >Win9x! The webgadget runs fine without the old ATL.dll from Compilers dir...
Hi ts-soft. You're absolutely right, it works without atl.dll; I should've tested more thoroughly. Thank you for pointing that out.
LuCiFeR[SD] wrote:add this to the registry...
[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\FeatureControl\Feature_Browser_Emulation]"yourExecutableName.exe"=dword:00002328
Hi LuCiFeR[SD], and thanks for the valuable tip; it works perfectly on both WinXP as well as Win7. Never would have figured that out.
AlanFoo wrote:...Does this solution needs all our end users' registries to be changed accordingly? Changing clients' registry setttings I try to avoid as much as I can. Am not sure... but can the .reg be directy run from PB runprogram like runprogram("c:\sample.reg") and it will update the registry directly? Have not tried that yet. Will anti virus software stops it?
Hello again Alan. Seems that LuCiFeR[SD] has found the solution. However, to answer your questions, this registry change has to be effected on any and all machines that are going to run the WebGadget() application for it to be able to use the latest/installed browser version. But the good news is, it's a painless and harmless registry entry that should not trigger any blocks or alarms, and it can be done from within your PureBasic application. I've written this short routine to validate the required registry entry, and consequently create it or modify it accordingly. You can place it at the top of an installation program, or even in the WebGadget() application itself:

Code: Select all

EnableExplicit

Define.s keyName, dwLabel, statusMsg, keyResult.i
Define.l dwValue, dwValueCheck, bufferSize

keyName = "Software\Microsoft\Internet Explorer\Main\FeatureControl\Feature_Browser_Emulation\"
dwLabel = "MyApplicationName.exe"
dwValue = 9000
bufferSize = SizeOf(Long)

If RegOpenKeyEx_(#HKEY_CURRENT_USER, keyName, 0, #KEY_ALL_ACCESS, @keyResult) = #ERROR_SUCCESS
  If keyResult And RegQueryValueEx_(keyResult, dwLabel, 0, 0, @dwValueCheck, @bufferSize) = #ERROR_SUCCESS
    If dwValueCheck = 9000 Or dwValueCheck = 8000
      RegCloseKey_(keyResult)
      statusMsg = "Entry Exists: Currently Set for IEv" + Str(dwValueCheck / 1000)
    Else
      If RegSetValueEx_(keyResult, @dwLabel, 0, #REG_DWORD, @dwValue, SizeOf(Long)) = #ERROR_SUCCESS
        RegCloseKey_(keyResult)
        statusMsg = "Existing Value Modified: WebGadget() set For IEv9"
      EndIf
    EndIf
  Else
    If RegSetValueEx_(keyResult, @dwLabel, 0, #REG_DWORD, @dwValue, SizeOf(Long)) = #ERROR_SUCCESS
      statusMsg = "New Value Created: WebGadget() set for IEv9"
    EndIf
  EndIf
Else
  If RegCreateKey_(#HKEY_CURRENT_USER, keyName, @keyResult) = #ERROR_SUCCESS
    If RegSetValueEx_(keyResult, @dwLabel, 0, #REG_DWORD, @dwValue, SizeOf(Long)) = #ERROR_SUCCESS
      statusMsg = "New Entry Created: WebGadget() set for IEv9"
    EndIf
  EndIf
EndIf

MessageRequester("WebGadget Emulation:", statusMsg)
I've tested it on WinXP and Win7 x64, and it worked even while logged in as a Guest user on Win7 without any administrator rights. Hope this approach will work for you, and once again, our thanks to LuCiFeR[SD] for the solution.
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel :D
rsts
Addict
Addict
Posts: 2736
Joined: Wed Aug 24, 2005 8:39 am
Location: Southwest OH - USA

Re: Has Purebasic upgraded the webgadget?

Post by rsts »

Wouldn't you need to check to determine if a correct version of IE was installed?

Or would it be OK even if one was not?

cheers
LuCiFeR[SD]
666
666
Posts: 1033
Joined: Mon Sep 01, 2003 2:33 pm

Re: Has Purebasic upgraded the webgadget?

Post by LuCiFeR[SD] »

not a 100% about that but on XP you cant run higher than IE8. so any OS newer than that will have IE8+ but It can't hurt to check :) although I don't know the best way to go about it.... but I shall investigate :)
LuCiFeR[SD]
666
666
Posts: 1033
Joined: Mon Sep 01, 2003 2:33 pm

Re: Has Purebasic upgraded the webgadget?

Post by LuCiFeR[SD] »

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer seems to show the currently installed version.. so might be worth reading from there first and setting the control accordingly.
AlanFoo
Enthusiast
Enthusiast
Posts: 172
Joined: Fri Jul 24, 2009 6:24 am
Location: Malaysia

Re: Has Purebasic upgraded the webgadget?

Post by AlanFoo »

TI-994A wrote:
ts-soft wrote:The ATL.dll is installed on all windows versions >Win9x! The webgadget runs fine without the old ATL.dll from Compilers dir...
Hi ts-soft. You're absolutely right, it works without atl.dll; I should've tested more thoroughly. Thank you for pointing that out.
LuCiFeR[SD] wrote:add this to the registry...
[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\FeatureControl\Feature_Browser_Emulation]"yourExecutableName.exe"=dword:00002328
Hi LuCiFeR[SD], and thanks for the valuable tip; it works perfectly on both WinXP as well as Win7. Never would have figured that out.
AlanFoo wrote:...Does this solution needs all our end users' registries to be changed accordingly? Changing clients' registry setttings I try to avoid as much as I can. Am not sure... but can the .reg be directy run from PB runprogram like runprogram("c:\sample.reg") and it will update the registry directly? Have not tried that yet. Will anti virus software stops it?
Hello again Alan. Seems that LuCiFeR[SD] has found the solution. However, to answer your questions, this registry change has to be effected on any and all machines that are going to run the WebGadget() application for it to be able to use the latest/installed browser version. But the good news is, it's a painless and harmless registry entry that should not trigger any blocks or alarms, and it can be done from within your PureBasic application. I've written this short routine to validate the required registry entry, and consequently create it or modify it accordingly. You can place it at the top of an installation program, or even in the WebGadget() application itself:

Code: Select all

EnableExplicit

Define.s keyName, dwLabel, statusMsg, keyResult.i
Define.l dwValue, dwValueCheck, bufferSize

keyName = "Software\Microsoft\Internet Explorer\Main\FeatureControl\Feature_Browser_Emulation\"
dwLabel = "MyApplicationName.exe"
dwValue = 9000
bufferSize = SizeOf(Long)

If RegOpenKeyEx_(#HKEY_CURRENT_USER, keyName, 0, #KEY_ALL_ACCESS, @keyResult) = #ERROR_SUCCESS
  If keyResult And RegQueryValueEx_(keyResult, dwLabel, 0, 0, @dwValueCheck, @bufferSize) = #ERROR_SUCCESS
    If dwValueCheck = 9000 Or dwValueCheck = 8000
      RegCloseKey_(keyResult)
      statusMsg = "Entry Exists: Currently Set for IEv" + Str(dwValueCheck / 1000)
    Else
      If RegSetValueEx_(keyResult, @dwLabel, 0, #REG_DWORD, @dwValue, SizeOf(Long)) = #ERROR_SUCCESS
        RegCloseKey_(keyResult)
        statusMsg = "Existing Value Modified: WebGadget() set For IEv9"
      EndIf
    EndIf
  Else
    If RegSetValueEx_(keyResult, @dwLabel, 0, #REG_DWORD, @dwValue, SizeOf(Long)) = #ERROR_SUCCESS
      statusMsg = "New Value Created: WebGadget() set for IEv9"
    EndIf
  EndIf
Else
  If RegCreateKey_(#HKEY_CURRENT_USER, keyName, @keyResult) = #ERROR_SUCCESS
    If RegSetValueEx_(keyResult, @dwLabel, 0, #REG_DWORD, @dwValue, SizeOf(Long)) = #ERROR_SUCCESS
      statusMsg = "New Entry Created: WebGadget() set for IEv9"
    EndIf
  EndIf
EndIf

MessageRequester("WebGadget Emulation:", statusMsg)
I've tested it on WinXP and Win7 x64, and it worked even while logged in as a Guest user on Win7 without any administrator rights. Hope this approach will work for you, and once again, our thanks to LuCiFeR[SD] for the solution.
Hi TI-994A,

Am really grateful to you and LuCiFeR[SD] your kind assistance.

I shall try it soonest...

Really saved me a lot lot of trouble and headaches :>)


Warmest regards
Alan
User avatar
TI-994A
Addict
Addict
Posts: 2705
Joined: Sat Feb 19, 2011 3:47 am
Location: Singapore
Contact:

Re: Has Purebasic upgraded the webgadget?

Post by TI-994A »

LuCiFeR[SD] wrote:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer seems to show the currently installed version.. so might be worth reading from there first and setting the control accordingly.
rsts wrote:Wouldn't you need to check to determine if a correct version of IE was installed?
Hi LuCiFeR[SD] & rsts. Good points, although, owing to the mechanics of the Browser Emulation feature, it may not be necessary.

The Browser Emulation settings for WebGadget() seem to work in a very peculiar way; WebGadget() defaults to IEv7 if this feature is not set, and honours settings only for browser versions higher than this. For example, in Win7 with IEv9 installed, WebGadget() can specifically target versions 7, 8 or 9; and in WinXP, which supports only upto IEv8, as LuCiFeR[SD] had pointed out, WebGadget() can only target versions 7 or 8. If we indicate any other versions outside of these ranges, higher or lower, it automatically defaults to the installed browser version. So, if the intention is to utilise the latest version, a higher setting should not pose a problem. I wonder if it could drop below IEv7?

In any case, it is always prudent to make the necessary validations, at least to confirm that Internet Explorer is indeed installed. This should do the trick:

Code: Select all

EnableExplicit

Define.s keyName, dwLabel, statusMsg, keyResult.i
Define.l dwValue, dwValueCheck, bufferSize, valType

keyName = "Software\Microsoft\Internet Explorer\"
dwLabel = "Version"
bufferSize = SizeOf(Long)

If RegOpenKeyEx_(#HKEY_LOCAL_MACHINE, keyName, 0, #KEY_READ, @keyResult) = #ERROR_SUCCESS
  If keyResult And RegQueryValueEx_(keyResult, dwLabel, 0, @valType, 0, @bufferSize) = #ERROR_SUCCESS
    dwValueCheck = AllocateMemory(bufferSize)
    If RegQueryValueEx_(keyResult, dwLabel, 0, 0, dwValueCheck, @bufferSize) = #ERROR_SUCCESS
      statusMsg = "Internet Explorer v." + PeekS(dwValueCheck) + " detected."
      RegCloseKey_(keyResult)
      FreeMemory(dwValueCheck)
      dwValueCheck = 0
    Else
      statusMsg = "Unable to determine Internet Explorer version."
    EndIf
  Else
    statusMsg = "Unable to determine Internet Explorer version."
  EndIf
Else
  statusMsg = "Unable to detect Internet Explorer."
EndIf

If MessageRequester("WebGadget Emulation:", statusMsg + " Proceed with registry validation?", #PB_MessageRequester_YesNo) = #PB_MessageRequester_No
  End
EndIf

keyName = "Software\Microsoft\Internet Explorer\Main\FeatureControl\Feature_Browser_Emulation\"
dwLabel = "MyApplicationName.exe"
dwValue = 9000
bufferSize = SizeOf(Long)

If RegOpenKeyEx_(#HKEY_CURRENT_USER, keyName, 0, #KEY_ALL_ACCESS, @keyResult) = #ERROR_SUCCESS
  If keyResult And RegQueryValueEx_(keyResult, dwLabel, 0, 0, @dwValueCheck, @bufferSize) = #ERROR_SUCCESS
    If dwValueCheck = 9000 Or dwValueCheck = 8000
      RegCloseKey_(keyResult)
      statusMsg = "Entry Exists: Currently Set for IEv" + Str(dwValueCheck / 1000)
    Else
      If RegSetValueEx_(keyResult, @dwLabel, 0, #REG_DWORD, @dwValue, SizeOf(Long)) = #ERROR_SUCCESS
        RegCloseKey_(keyResult)
        statusMsg = "Existing Value Modified: WebGadget() set For IEv9"
      EndIf
    EndIf
  Else
    If RegSetValueEx_(keyResult, @dwLabel, 0, #REG_DWORD, @dwValue, SizeOf(Long)) = #ERROR_SUCCESS
      statusMsg = "New Value Created: WebGadget() set for IEv9"
    EndIf
  EndIf
Else
  If RegCreateKey_(#HKEY_CURRENT_USER, keyName, @keyResult) = #ERROR_SUCCESS
    If RegSetValueEx_(keyResult, @dwLabel, 0, #REG_DWORD, @dwValue, SizeOf(Long)) = #ERROR_SUCCESS
      statusMsg = "New Entry Created: WebGadget() set for IEv9"
    EndIf
  EndIf
EndIf

MessageRequester("WebGadget Emulation:", statusMsg)
It's the same code as before, only with the Internet Explorer version-check inserted at the top.

And here's another neat trick, although I'm not sure if it will work across the board: if we substitute the application name (MyApplicationName.exe in the example) with PureBasic_Compilation0.exe, we can use the targeted browser emulation from within the PureBasic IDE itself. Very convenient for testing and debugging.
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel :D
AlanFoo
Enthusiast
Enthusiast
Posts: 172
Joined: Fri Jul 24, 2009 6:24 am
Location: Malaysia

Re: Has Purebasic upgraded the webgadget?

Post by AlanFoo »

TI-994A wrote:
LuCiFeR[SD] wrote:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer seems to show the currently installed version.. so might be worth reading from there first and setting the control accordingly.
rsts wrote:Wouldn't you need to check to determine if a correct version of IE was installed?
Hi LuCiFeR[SD] & rsts. Good points, although, owing to the mechanics of the Browser Emulation feature, it may not be necessary.

The Browser Emulation settings for WebGadget() seem to work in a very peculiar way; WebGadget() defaults to IEv7 if this feature is not set, and honours settings only for browser versions higher than this. For example, in Win7 with IEv9 installed, WebGadget() can specifically target versions 7, 8 or 9; and in WinXP, which supports only upto IEv8, as LuCiFeR[SD] had pointed out, WebGadget() can only target versions 7 or 8. If we indicate any other versions outside of these ranges, higher or lower, it automatically defaults to the installed browser version. So, if the intention is to utilise the latest version, a higher setting should not pose a problem. I wonder if it could drop below IEv7?

In any case, it is always prudent to make the necessary validations, at least to confirm that Internet Explorer is indeed installed. This should do the trick:

Code: Select all

EnableExplicit

Define.s keyName, dwLabel, statusMsg, keyResult.i
Define.l dwValue, dwValueCheck, bufferSize, valType

keyName = "Software\Microsoft\Internet Explorer\"
dwLabel = "Version"
bufferSize = SizeOf(Long)

If RegOpenKeyEx_(#HKEY_LOCAL_MACHINE, keyName, 0, #KEY_READ, @keyResult) = #ERROR_SUCCESS
  If keyResult And RegQueryValueEx_(keyResult, dwLabel, 0, @valType, 0, @bufferSize) = #ERROR_SUCCESS
    dwValueCheck = AllocateMemory(bufferSize)
    If RegQueryValueEx_(keyResult, dwLabel, 0, 0, dwValueCheck, @bufferSize) = #ERROR_SUCCESS
      statusMsg = "Internet Explorer v." + PeekS(dwValueCheck) + " detected."
      RegCloseKey_(keyResult)
      FreeMemory(dwValueCheck)
      dwValueCheck = 0
    Else
      statusMsg = "Unable to determine Internet Explorer version."
    EndIf
  Else
    statusMsg = "Unable to determine Internet Explorer version."
  EndIf
Else
  statusMsg = "Unable to detect Internet Explorer."
EndIf

If MessageRequester("WebGadget Emulation:", statusMsg + " Proceed with registry validation?", #PB_MessageRequester_YesNo) = #PB_MessageRequester_No
  End
EndIf

keyName = "Software\Microsoft\Internet Explorer\Main\FeatureControl\Feature_Browser_Emulation\"
dwLabel = "MyApplicationName.exe"
dwValue = 9000
bufferSize = SizeOf(Long)

If RegOpenKeyEx_(#HKEY_CURRENT_USER, keyName, 0, #KEY_ALL_ACCESS, @keyResult) = #ERROR_SUCCESS
  If keyResult And RegQueryValueEx_(keyResult, dwLabel, 0, 0, @dwValueCheck, @bufferSize) = #ERROR_SUCCESS
    If dwValueCheck = 9000 Or dwValueCheck = 8000
      RegCloseKey_(keyResult)
      statusMsg = "Entry Exists: Currently Set for IEv" + Str(dwValueCheck / 1000)
    Else
      If RegSetValueEx_(keyResult, @dwLabel, 0, #REG_DWORD, @dwValue, SizeOf(Long)) = #ERROR_SUCCESS
        RegCloseKey_(keyResult)
        statusMsg = "Existing Value Modified: WebGadget() set For IEv9"
      EndIf
    EndIf
  Else
    If RegSetValueEx_(keyResult, @dwLabel, 0, #REG_DWORD, @dwValue, SizeOf(Long)) = #ERROR_SUCCESS
      statusMsg = "New Value Created: WebGadget() set for IEv9"
    EndIf
  EndIf
Else
  If RegCreateKey_(#HKEY_CURRENT_USER, keyName, @keyResult) = #ERROR_SUCCESS
    If RegSetValueEx_(keyResult, @dwLabel, 0, #REG_DWORD, @dwValue, SizeOf(Long)) = #ERROR_SUCCESS
      statusMsg = "New Entry Created: WebGadget() set for IEv9"
    EndIf
  EndIf
EndIf

MessageRequester("WebGadget Emulation:", statusMsg)
It's the same code as before, only with the Internet Explorer version-check inserted at the top.

And here's another neat trick, although I'm not sure if it will work across the board: if we substitute the application name (MyApplicationName.exe in the example) with PureBasic_Compilation0.exe, we can use the targeted browser emulation from within the PureBasic IDE itself. Very convenient for testing and debugging.
Hello TI-994A

Very informative.

One question.

On the "MyApplicationName.exe" and the routine you provided.
I have more than one .exe program using webgadget and having different names.

Do i have to set for each one of the exe file?

and also should the path of the exe be mentioned e.g "c:\visless\myapplicationName.exe" rather than just "myapplicationName.exe"?

this would mean if I have 10 exes...there would be 10 entries to the registry. Am I right?

Thanks
Alan
User avatar
TI-994A
Addict
Addict
Posts: 2705
Joined: Sat Feb 19, 2011 3:47 am
Location: Singapore
Contact:

Re: Has Purebasic upgraded the webgadget?

Post by TI-994A »

AlanFoo wrote:...I have more than one .exe program using webgadget and having different names.

Do i have to set for each one of the exe file? - Yes.

and also should the path of the exe be mentioned e.g "c:\visless\myapplicationName.exe" rather than just "myapplicationName.exe"? - No.

this would mean if I have 10 exes...there would be 10 entries to the registry. Am I right? - Yes.
Hi Alan. You're right; each and every separate application that utilises the WebGadget() would require an entry in the Feature_Browser_Emulation folder. And no, the installation path is not required, only the full application name with the .exe extension.

You can easily demonstrate this by launching your app from a different folder; you'll notice that it still complies with the browser emulation. But if you changed the app executable filename, it will revert back to utilising the default IEv7.

Hope this answers your questions.
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel :D
AlanFoo
Enthusiast
Enthusiast
Posts: 172
Joined: Fri Jul 24, 2009 6:24 am
Location: Malaysia

Re: Has Purebasic upgraded the webgadget?

Post by AlanFoo »

TI-994A wrote:
AlanFoo wrote:...I have more than one .exe program using webgadget and having different names.

Do i have to set for each one of the exe file? - Yes.

and also should the path of the exe be mentioned e.g "c:\visless\myapplicationName.exe" rather than just "myapplicationName.exe"? - No.

this would mean if I have 10 exes...there would be 10 entries to the registry. Am I right? - Yes.
Hi Alan. You're right; each and every separate application that utilises the WebGadget() would require an entry in the Feature_Browser_Emulation folder. And no, the installation path is not required, only the full application name with the .exe extension.

You can easily demonstrate this by launching your app from a different folder; you'll notice that it still complies with the browser emulation. But if you changed the app executable filename, it will revert back to utilising the default IEv7.

Hope this answers your questions.
Got it and thanks.

Regards
Alan
User avatar
RichAlgeni
Addict
Addict
Posts: 935
Joined: Wed Sep 22, 2010 1:50 am
Location: Bradenton, FL

Re: Has Purebasic upgraded the webgadget?

Post by RichAlgeni »

Thanks for that folks!

Now, is there a way to get around the JavaScript error?
AlanFoo
Enthusiast
Enthusiast
Posts: 172
Joined: Fri Jul 24, 2009 6:24 am
Location: Malaysia

Re: Has Purebasic upgraded the webgadget?

Post by AlanFoo »

RichAlgeni wrote:Thanks for that folks!

Now, is there a way to get around the JavaScript error?
Yes there is... Got it from this forum.
e.g.

WebGadget(4, 10, 10, #WindowWidth, #WindowHeight-60,"www.visitwebsite.com" )

myBrowser.IWebBrowser2 = GetWindowLong_(GadgetID(400), #GWL_USERDATA)
myBrowser\put_Silent(#True)

You will not see the javascript error anymore.

I wonder if using the IE9 emulator, if this previous Javascript error will still persist?
Maybe you can find out as my webgadget does not now give this error unlike before.

Hope this helps.

Regards
Alan
User avatar
RichAlgeni
Addict
Addict
Posts: 935
Joined: Wed Sep 22, 2010 1:50 am
Location: Bradenton, FL

Re: Has Purebasic upgraded the webgadget?

Post by RichAlgeni »

Thanks Alan!
Post Reply