请教高手C#连接网路磁蝶机的方法

来源:百度知道 编辑:UC知道 时间:2024/05/17 02:06:54
请教高手C#连接网路磁蝶机的方法

只知道C++版本的。
int GetRoot(float a,float b,float c,double *root)
{
double delta,deltasqrt;
delta=b*b-4.0*a*c;
if(delta<0.0) return 0; //无根
deltasqrt=sqrt(delta);
if(a!=0)
{
root[0]=(-b+deltasqrt)/(2.0*a);
root[1]=(-b-deltasqrt)/(2.0*a);
}
else
if(b!=0.0) root[0]=root[1]=-c/b;
else
return 0;
if(root[0]==root[1]) return 1;
else return 2;
}
char str[80];
LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM); //窗口过程
int WINAPI WinMain(
HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
float a=2.0,b=6.0,c=3.0;
double root[2];
int n=GetRoot(a,b,c,root);
if(n<1)
strcpy(str,"方程无根!"); //字符串复制
else
sprintf(str,"方程的解为:%f,%f",root[0],root[1]); //将实数转换成字符串

HWND hwnd;
MSG msg;
WNDCLASS wndclass;
wndclass.style=CS_HREDRAW | CS_V