我使用C++ builder 5並在程序中獲得了一些鏈接。我希望這些鏈接在默認系統瀏覽器或Firefox中打開,如果默認爲無選項的話。在C++ builder中設置默認瀏覽器5
我用:
ShellExecute(NULL, "open", "http://maps.google.nl/maps?f=q&hl=nl&q=", NULL, NULL, SW_SHOWNORMAL);
但對一些鏈接也不會與已存在的代碼工作。
// this is not working
case 4: if(Qry_shipment->RecordCount == 0){return;}
webaddress = "http://maps.google.nl/maps?f=q&hl=nl&q=";
//we need the info from clicked shipment-not from overflow
if(Qry_shipment->FieldByName("tstohn")->AsString == pAuthorization[7])
{
webaddress = webaddress
+ Qry_shipment->FieldByName("tslpla")->AsString + ","
+ Qry_shipment->FieldByName("tslzcd")->AsString + ","
+ Qry_shipment->FieldByName("lalaad")->AsString;
}
else
{
webaddress = webaddress
+ Qry_shipment->FieldByName("tsupla")->AsString + ","
+ Qry_shipment->FieldByName("tsuzcd")->AsString + ","
+ Qry_shipment->FieldByName("lalos")->AsString;
}
break;
有可能的代碼PICE如此,所以我不必須編輯所有的鏈接我可以定義程序它自己默認的瀏覽器。
你到底有什麼問題?瀏覽器是否顯示但不打開您的頁面(確保您的URL構建正確),還是ShellExecute自行失敗? – Stan
ShellExecute *將*使用默認瀏覽器打開URL。如果在從數據庫添加參數時代碼失敗,請告訴我們失敗的完整URL。由於我不是心靈上的,我無法推斷出你的數據庫的內容...... – Roddy