RSS订阅悠然探索,悠然索取
你的位置:首页
未分类

C# 绿色IIS

C# 绿色IIS

 

private void button1_Click(object sender, EventArgs e)
{
    if (this.button1.Text == "启动服务")
    {
        if ((this.textBox1.Text == "") || (this.textBox1.Text == "0"))
        {
            MessageBox.Show("请输入端口");
        }
        else if (Convert.ToInt32(this.textBox1.Text) > 0xffff)
        {
            MessageBox.Show("端口范围错误!在(1~65535)之间未使用的端口.");
        }
        else if (this.textBox2.Text == "")
        {
            MessageBox.Show("请选择网站目录");
        }
        else
        {
            if (this.textBox3.Text == "")
            {
                this.textBox3.Text = "/";
            }
            if (this.comboBox1.GetItemText(this.comboBox1.SelectedItem) == "v4.0")
            {
                if (!File.Exists(@"c:\WebServer40.EXE"))
                {
                    File.WriteAllBytes(@"c:\WebServer40.EXE", Files.WebDev_WebServer40);
                }
                this.p = Process.Start(@"c:\WebServer40.EXE", "/port:" + this.textBox1.Text + " /path:\"" + this.textBox2.Text + "\" /vpath:\"" + this.textBox3.Text + "\"");
                this.pid = this.p.Id;
            }
            else
            {
                if (!File.Exists(@"c:\WebServer20.EXE"))
                {
                    File.WriteAllBytes(@"c:\WebServer20.EXE", Files.WebDev_WebServer40);
                }
                this.p = Process.Start(@"c:\WebServer20.EXE", "/port:" + this.textBox1.Text + " /path:\"" + this.textBox2.Text + "\" /vpath:\"" + this.textBox3.Text + "\"");
                this.pid = this.p.Id;
            }
            this.toolStripStatusLabel1.Text = "启动成功!";
            this.button1.Text = "停止服务";
        }
    }
    else
    {
        this.p.Kill();
        this.pid = 0;
        this.toolStripStatusLabel1.Text = "服务已经关闭!";
        this.button1.Text = "启动服务";
    }
}

发布时间:2014年12月1日 标签:

未分类

C#执行DOS命令,返回结果

C#执行DOS命令,返回结果

public string Dir(string strcmd)
{
    Process process = new Process();
    process.StartInfo.FileName = "cmd.exe";
    process.StartInfo.UseShellExecute = false;
    process.StartInfo.RedirectStandardInput = true;
    process.StartInfo.RedirectStandardOutput = true;
    process.StartInfo.RedirectStandardError = true;
    process.StartInfo.CreateNoWindow = true;
    process.Start();
    process.StandardOutput.DiscardBufferedData();
    process.StandardInput.WriteLine(strcmd);
    process.StandardInput.WriteLine("exit");
    process.WaitForExit();
    return process.StandardOutput.ReadToEnd();
}

发布时间:2014年12月1日 标签:

未分类

c#调用c++并实现回调

c#调用c++并实现回调

 

 typedef bool (CALLBACK *CareffReceive)(char *pBuf, int nBufSize);

CareffReceive m_Call ;  //回复信息的回调函数
bool m_CallTrue=false;

 

extern "C"__declspec(dllexport)BOOL WINAPI CareffCallback(CareffReceive InfoReceive)
{
 m_Call = InfoReceive;
 //int i=1001;
 //char * a = "hello";
 //m_Call(a,i);   //recv 为 char *, nLen 为 int
 m_CallTrue=true;
 return m_CallTrue;
 //m_RecInfoCall(recv,nLen);   //recv 为 char *, nLen 为 int
}

发布时间:2014年11月19日 标签:

未分类

获取硬件信息

获取硬件信息

aliyun:   1789FBFF000206D70000000000000000
localhost:BFEBFBFF0001067A2CB4307D00000000
JHMC:     1FABFBFF000206D70000000000000000
MDEDU:    1FABFBFF000306E40000000000000000

发布时间:2014年11月19日 标签:

未分类

CString,int,string,char*之间的转换

CString,int,string,char*之间的转换

 1 CString,int,string,char*之间的转换 
string 转 CString 
CString.format("%s", string.c_str()); 
char 转 CString 
CString.format("%s", char*); 
char 转 string 
string s(char *); 
string 转 char * 
char *p = string.c_str(); 
CString 转 string 
string s(CString.GetBuffer()); 
1,string -> CString 
CString.format("%s", string.c_str()); 
用c_str()确实比data()要好. 
2,char -> string 
string s(char *); 
你的只能初始化,在不是初始化的地方最好还是用assign(). 
3,CString -> string 
string s(CString.GetBuffer()); 
GetBuffer()后一定要ReleaseBuffer(),否则就没有释放缓冲区所占的空间. 

《C++标准函数库》中说的 
有三个函数可以将字符串的内容转换为字符数组和C—string 
1.data(),返回没有”\0“的字符串数组 
2,c_str(),返回有”\0“的字符串数组 
3,copy() 

CString互转int 
将字符转换为整数,可以使用atoi、_atoi64或atol。 
而将数字转换为CString变量,可以使用CString的Format函数。如 
CString s; 
int i = 64; 
s.Format("%d", i) 
Format函数的功能很强,值得你研究一下。 
void CStrDlg::OnButton1() 
{ 
// TODO: Add your control notification handler code here 
CString 
ss="1212.12"; 
int temp=atoi(ss); 
CString aa; 
aa.Format("%d",temp); 
AfxMessageBox("var is " + aa); 
} 
sart.Format("%s",buf); 
CString互转char* 
///char * TO cstring 
CString strtest; 
char * charpoint; 
charpoint="give string a value"; 
strtest=charpoint; 

///cstring TO char * 
charpoint=strtest.GetBuffer(strtest.GetLength()); 
标准C里没有string,char *==char []==string 
可以用CString.Format("%s",char *)这个方法来将char *转成CString。要把CString转成char *,用操作符(LPCSTR)CString就可以了。 

CString转换 char[100] 
char a[100]; 
CString str("aaaaaa"); 
strncpy(a,(LPCTSTR)str,sizeof(a)); 
2 CString类型的转换成int 
CString类型的转换成int 
将字符转换为整数,可以使用atoi、_atoi64或atol。 
//CString aaa = "16" ; 
//int int_chage = atoi((lpcstr)aaa) ; 

而将数字转换为CString变量,可以使用CString的Format函数。如 
CString s; 
int i = 64; 
s.Format("%d", i) 
Format函数的功能很强,值得你研究一下。 
如果是使用char数组,也可以使用sprintf函数。 
//CString ss="1212.12"; 
//int temp=atoi(ss); 
//CString aa; 
//aa.Format("%d",temp); 

数字->字符串除了用CString::Format,还有FormatV、sprintf和不需要借助于Afx的itoa 

3 char* 在装int 
#include <stdlib.h> 

int atoi(const char *nptr); 
long atol(const char *nptr); 
long long atoll(const char *nptr); 
long long atoq(const char *nptr); 

4 CString,int,string,char*之间的转换 
string aa("aaa"); 
char *c=aa.c_str(); 

cannot convert from 'const char *' to 'char *' 
const char *c=aa.c_str(); 

5 CString,int,string,char*之间的转换 
string.c_str()只能转换成const char *, 
要转成char *这样写: 
string mngName; 
char t[200]; memset(t,0,200); strcpy(t,mngName.c_str());

发布时间:2014年11月14日 标签:

未分类

c++数据库

c++数据库

 

(1)、引入ADO类

发布时间:2014年11月13日 标签:

未分类

C++读写文件

C++读写文件

 

在看C++编程思想中,每个练习基本都是使用ofstream,ifstream,fstream,以前粗略知道其用法和含义,在看了几位大牛的博文后,进行整理和总结:

发布时间:2014年11月10日 标签:

未分类

没有namespace C++竟然编译不过去

没有namespace C++竟然编译不过去

 没有namespace C++竟然编译不过去

发布时间:2014年11月7日 标签:

未分类

ASP.NET应用C++dll 返回字符串

ASP.NET应用C++dll 返回字符串

 

#include "sky_file.h"
#include <iostream> 
#include <fstream> 
#include <string> 
#include <vector> 
#include <ios> 
#include <windows.h> 

发布时间:2014年11月7日 标签:

asp.net安全

ASP.NET引用C++的DLL

ASP.NET引用C++的DLL

 

发布时间:2014年11月7日 标签:

«101112131415161718192021222324»
控制面板
您好,欢迎到访网站!
  [查看权限]
网站分类
搜索
最新留言
网站收藏
友情链接
图标汇集