//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
String nowIs;
String getCurDir;
String getFileName;
String newStr;
if(OpenDialog1->Execute()) {
RadioButton1->Checked=true;
nowIs=OpenDialog1->FileName;
getCurDir=GetCurrentDir();
getFileName=ExtractFileName(nowIs);
newStr=getCurDir+"/"+getFileName;
TReplaceFlags Flags;
Edit1->Text=StringReplace(newStr, "F:\\PHPtools\\Apache2.4\\Apache24\\htdocs\\", "",Flags<<rfReplaceAll);
Memo1->Lines->LoadFromFile(newStr);
Button1->Click();
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
String getWeb=Edit1->Text;
String PHP_SERVER="http://127.0.0.1/"+getWeb;
String JSP_SERVER="http://127.0.0.1:8080/"+getWeb;
String ASP_SERVER="http://127.0.0.1/"+getWeb;
char *php=new char[256];
char *jsp=new char[256];
char *asp=new char[256];
//StrPCopy(Arr,Str);用于把string變為字符陣列
//extern PACKAGE char * __fastcall StrPCopy(char * Dest, const AnsiString Source);
//StrPCopy(szBuffer, Label1->Caption);
StrPCopy(php,PHP_SERVER);
StrPCopy(jsp,JSP_SERVER);
StrPCopy(asp,ASP_SERVER);
if(RadioButton1->Checked) {
StaticText1->Caption=PHP_SERVER;
//ShellExecute(Handle, "open", "firefox.exe", "about:blank", NULL, SW_SHOWNORMAL);
ShellExecute(Handle, "open", "firefox.exe", php, NULL, SW_SHOWNORMAL);
}
else if(RadioButton2->Checked) {
StaticText1->Caption=JSP_SERVER;
//ShellExecute(Handle, "open", "firefox.exe", "about:blank", NULL, SW_SHOWNORMAL);
ShellExecute(Handle, "open", "firefox.exe", jsp, NULL, SW_SHOWNORMAL);
}
else if(RadioButton4->Checked) {
StaticText1->Caption=ASP_SERVER;
//ShellExecute(Handle, "open", "firefox.exe", "about:blank", NULL, SW_SHOWNORMAL);
ShellExecute(Handle, "open", "firefox.exe", asp, NULL, SW_SHOWNORMAL);
}
else if(RadioButton3->Checked) {
StaticText1->Caption="測驗網頁的本地服務器已關閉,請選擇測驗服務器..";
}
else {
ShowMessage(" 錯誤! 你沒有選擇任何本地服務器. ");
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::RadioButton2Click(TObject *Sender)
{
WinExec("net stop apache2.4", SW_HIDE); // 關閉apache2.4服務
WinExec("net stop W3SVC", SW_HIDE); // 關閉IIS9服務
WinExec("net start tomcat8", SW_HIDE); // 開啟tomcat8服務
//WinExec("net start mysql56", SW_HIDE); // 開啟mysql56服務
}
//---------------------------------------------------------------------------
void __fastcall TForm1::RadioButton3Click(TObject *Sender)
{
WinExec("net stop apache2.4", SW_HIDE); // 關閉apache2.4服務
WinExec("net stop tomcat8", SW_HIDE); // 關閉tomcat8服務
WinExec("net stop W3SVC", SW_HIDE); // 關閉IIS9服務
WinExec("net stop mysql56", SW_HIDE); // 關閉mysql56服務
}
//---------------------------------------------------------------------------
void __fastcall TForm1::RadioButton1Click(TObject *Sender)
{
WinExec("net stop tomcat8", SW_HIDE); // 關閉tomcat8服務
WinExec("net stop W3SVC", SW_HIDE); // 關閉IIS9服務
WinExec("net start apache2.4", SW_HIDE); // 開啟apache2.4服務
//WinExec("net start mysql56", SW_HIDE); // 開啟mysql56服務
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button3Click(TObject *Sender)
{
String nowIs;
String getCurDir;
String getFileName;
String newStr;
if(OpenDialog2->Execute()) {
RadioButton2->Checked=true;
nowIs=OpenDialog2->FileName;
getCurDir=GetCurrentDir();
getFileName=ExtractFileName(nowIs);
newStr=getCurDir+"/"+getFileName;
TReplaceFlags Flags;
Edit1->Text=StringReplace(newStr, "D:\\apache-tomcat-8.0.21\\webapps\\", "",Flags<<rfReplaceAll);
Memo1->Lines->LoadFromFile(newStr);
Button1->Click();
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button4Click(TObject *Sender)
{
if(RadioButton1->Checked) {
if(SaveDialog1->Execute()) {
Memo1->Lines->SaveToFile(SaveDialog1->FileName);
Edit1->Text=ExtractFileName(SaveDialog1->FileName);
Button1->Click();
}
}
else if(RadioButton2->Checked) {
if(SaveDialog2->Execute()) {
Memo1->Lines->SaveToFile(SaveDialog2->FileName);
Edit1->Text=ExtractFileName(SaveDialog2->FileName);
Button1->Click();
}
}
else if(RadioButton4->Checked) {
if(SaveDialog3->Execute()) {
Memo1->Lines->SaveToFile(SaveDialog3->FileName);
Edit1->Text=ExtractFileName(SaveDialog3->FileName);
Button1->Click();
}
}
else {
if(SaveDialog1->Execute()) {
Memo1->Lines->SaveToFile(SaveDialog1->FileName);
Edit1->Text=ExtractFileName(SaveDialog1->FileName);
Button1->Click();
}
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::BitBtn1Click(TObject *Sender)
{
String phpPath="F:\\PHPtools\\Apache2.4\\Apache24\\htdocs\\";
String jspPath="D:\\apache-tomcat-8.0.21\\webapps\\";
String aspPath="C:\\inetpub\\wwwroot\\";
String htmlPaht="F:\\PHPtools\\Apache2.4\\Apache24\\htdocs\\";
if(RadioButton1->Checked) {
//if(SaveDialog1->Execute()) {
Memo1->Lines->SaveToFile(phpPath+"tmp_page.php");
Edit1->Text=ExtractFileName("tmp_page.php");
Button1->Click();
//}
}
else if(RadioButton2->Checked) {
//if(SaveDialog2->Execute()) {
Memo1->Lines->SaveToFile(jspPath+"tmp_page.jsp");
Edit1->Text=ExtractFileName("tmp_page.jsp");
Button1->Click();
//}
}
else if(RadioButton4->Checked) {
//if(SaveDialog2->Execute()) {
Memo1->Lines->SaveToFile(jspPath+"tmp_page.asp");
Edit1->Text=ExtractFileName("tmp_page.asp");
Button1->Click();
//}
}
else {
//if(SaveDialog1->Execute()) {
Memo1->Lines->SaveToFile(phpPath+"tmp_page.html");
Edit1->Text=ExtractFileName("tmp_page.html");
Button1->Click();
//}
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
WinExec("net start mysql56", SW_HIDE);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormClose(TObject *Sender, TCloseAction &Action)
{
RadioButton3->Checked=true;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button5Click(TObject *Sender)
{
RadioButton3->Checked=true;
Close();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::RadioButton4Click(TObject *Sender)
{
WinExec("net stop apache2.4", SW_HIDE); // 關閉apache2.4服務
WinExec("net stop tomcat8", SW_HIDE); // 關閉tomcat8服務
WinExec("net start w3svc", SW_HIDE); // 開啟apache2.4服務
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button6Click(TObject *Sender)
{
String nowIs;
String getCurDir;
String getFileName;
String newStr;
if(OpenDialog3->Execute()) {
RadioButton4->Checked=true;
nowIs=OpenDialog3->FileName;
getCurDir=GetCurrentDir();
getFileName=ExtractFileName(nowIs);
newStr=getCurDir+"/"+getFileName;
TReplaceFlags Flags;
Edit1->Text=StringReplace(newStr, "C:\\inetpub\\wwwroot\\", "",Flags<<rfReplaceAll);
Memo1->Lines->LoadFromFile(newStr);
Button1->Click();
}
}
//---------------------------------------------------------------------------
l
uj5u.com熱心網友回復:
不過,這個程式只能生成一級目錄,http與本地檔案的分隔符不同,一個是/ 一個是 \ 不知道如何轉換??uj5u.com熱心網友回復:
不知是否有用?⑻ExpandUNCFileName()
原型:extern PACKAGE AnsiString __fastcall ExpandUNCFileName(const AnsiString FileName);
功能:回傳含有網路驅動器的檔案全路徑,格式為://機器名/共享名/檔案名
引數:FileName:要處理的檔案名
例:ShowMessage(ExpandUNCFileName("F:\\Winnt\\SOL.EXE"));/*如果F:是映射的網路驅動器//NT40/WINNT,則顯示"//NT40/WINNT/SOL.EXE"*/
uj5u.com熱心網友回復:
UnicodeString __fastcall StringReplace(const System::UnicodeString S,
const System::UnicodeString OldPattern,
const System::UnicodeString NewPattern,
TReplaceFlags Flags)
說明:
1.引數S,需要修改的字串
2.引數OldPattern,需要替換的子串
3.引數NewPattern,用以替換的新子串
4.引數 TReplaceFlags Flags 替換標識,包含rfReplaceAll和rfIgnoreCase,rfReplaceAll用來確定是否替換全部的子串,rfIgnoreCase用來確定是否區分字母的大小寫。
例子:
AnsiString str = "你帥,你很帥,你非常帥";
AnsiString sNewStr = StringReplace(str,"帥","漂亮",TReplaceFlags()<<rfReplaceAll<<rfIgnoreCase);
retrun sNewStr;
回傳值:"你漂亮,你很漂亮,你非常漂亮"
uj5u.com熱心網友回復:
u010165006非常謝謝你,我的問題解決了……uj5u.com熱心網友回復:
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/74448.html
標籤:網絡及通訊開發
