写好的C代码怎样变成软件
你是c语言的初学者吗?你意思是你编的dos那种界面,想换成windows界面,那你就要在vc6里面新建MFC appwisard 下面给你一个用c++语言生成一个简单的点击弹出对话框示例代码:用c语言写界面实在太麻烦了,太难了。
如果你没有学过c++,那我给你个最实际的办法,你在vc里面把你的代码生成dll,然后在vb里面调用。
vb很容易做windows界面这是众所周知的。
#include #include #include LRESULT CALLBACK MainWndProc (HWND hwnd, UINT nMsg, WPARAM wParam, LPARAM lParam) {/* The window handle for the "Click Me" button. */ static HWND hwndButton = 0; static int cx, cy;/* Height and width of our button. */ HDC hdc;/* A device context used for drawing */ PAINTSTRUCT ps;/* Also used during window drawing */ RECT rc;/* A rectangle used during drawing */ switch (nMsg) { case WM_CREATE:{ TEXTMETRIC tm; hdc = GetDC (hwnd); SelectObject (hdc, GetStockObject (SYSTEM_FIXED_FONT)); GetTextMetrics (hdc, &tm); cx = tm.tmAveCharWidth * 30; cy = (tm.tmHeight + tm.tmExternalLeading) * 2; ReleaseDC (hwnd, hdc);/* Now create the button */ hwndButton = CreateWindow ("button",/* Builtin button class */"Click Here",WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,0, 0, cx, cy,hwnd,/* Parent is this window. */(HMENU) 1,/* Control ID: 1 */((LPCREATESTRUCT) lParam)->hInstance,NULL); return 0; break; } case WM_DESTROY:PostQuitMessage (0); return 0; break; case WM_PAINT:hdc = BeginPaint (hwnd, &ps); GetClientRect (hwnd, &rc); rc.bottom = rc.bottom / 2; DrawText (hdc, "Hello, World!", -1, &rc,DT_SINGLELINE | DT_CENTER | DT_VCENTER); EndPaint (hwnd, &ps); return 0; break; case WM_SIZE:if (hwndButton &&(wParam == SIZEFULLSCREEN || wParam == SIZENORMAL) ) { rc.left = (LOWORD(lParam) - cx) / 2; rc.top = HIWORD(lParam) * 3 / 4 - cy / 2; MoveWindow ( hwndButton,rc.left, rc.top, cx, cy, TRUE); } break; case WM_COMMAND:if (LOWORD(wParam) == 1 && HIWORD(wParam) == BN_CLICKED && (HWND) lParam == hwndButton) { DestroyWindow (hwnd); } return 0; break; } return DefWindowProc (hwnd, nMsg, wParam, lParam); } int STDCALL; WinMain (HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpCmd, int nShow) { HWND hwndMain;/* Handle for the main window. */ MSG msg;/* A Win32 message structure. */ WNDCLASSEX wndclass;/* A window class structure. */ char*szMainWndClass = "WinTestWin"; memset (&wndclass, 0, sizeof(WNDCLASSEX)); wndclass.lpszClassName = szMainWndClass; wndclass.cbSize = sizeof(WNDCLASSEX); wndclass.style = CS_HREDRAW | CS_VREDRAW; wndclass.lpfnWndProc = MainWndProc; wndclass.hInstance = hInst; wndclass.hIcon = LoadIcon (NULL, IDI_APPLICATION); wndclass.hIconSm = LoadIcon (NULL, IDI_APPLICATION); wndclass.hCursor = LoadCursor (NULL, IDC_ARROW); wndclass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH); RegisterClassEx (&wndclass); hwndMain = CreateWindow ( szMainWndClass,/* Class name */"Hello",/* Caption */ WS_OVERLAPPEDWINDOW,/* Style */ CW_USEDEFAULT,/* Initial x (use default) */ CW_USEDEFAULT,/* Initial y (use default) */ CW_USEDEFAULT,/* Initial x size (use default) */ CW_USEDEFAULT,/* Initial y size (use default) */ NULL,/* No parent window */ NULL,/* No menu */ hInst,/* This program instance */ NULL/* Creation parameters */); ShowWindow (hwndMain, nShow); UpdateWindow (hwndMain); while (GetMessage (&msg, NULL, 0, 0)) { TranslateMessage (&msg); DispatchMessage (&msg); } return msg.wParam; }
怎么将源码变成软件或脚本呢,要下载什么工具?
如果你安装的是.net framework 2.0的框架 可以用C:\WINDOWS\Microsoft.NET\Framework\v2.0.5\csc.exe来编译C#文件如果你安装的是.net framework 3.5的框架 可以用C:\WINDOWS\Microsoft.NET\Framework\v3.5\csc.exe来编译C#文件或者去安装Visual Studio 2008这个IDE来进行可视化的 操作!
优柔寡断你二舅