
正文
c语言api函数实例 c语言api怎么用
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
c语言中API函数的使用
api函数要用C++.
调用其他exe程序,c语言中用
char
my_cmd[80]="my_prog_name.exe";
system(my_cmd);
就可以了。
查询运行窗口
....
这些都是
设及
视窗
的函数,建窗口,显示窗口,关闭窗口,查询等,都有函数。你只要
包括了相关的头文件,调用相应函数,给入实际参数,就可以了。不难,只是繁杂,时不时要查帮助文件,初学者要有耐心,熟能生巧。
相关问答
Q1: C语言中怎么使用API函数 求使用方法
api函数要用C++.
调用其c语言api函数实例他exe程序,c语言中用
char my_cmd[80]="my_prog_name.exe";
system(my_cmd); 就可以了。
查询运行窗口 .... 这些都是 设及 视窗 c语言api函数实例的函数c语言api函数实例,建窗口c语言api函数实例,显示窗口,关闭窗口,查询等,都有函数。c语言api函数实例你只要 包括了相关的头文件,调用相应函数,给入实际参数,就可以了。不难,只是繁杂,时不时要查帮助文件,
Q2: C语言能直接对API函数进行操作吗
API都是C写的, 反过来也成,
你使用VC来做C程序, 可以直接用API
例子:
// DD.cpp : Defines the entry point for the application.
//
#include "stdafx.h"
#include "resource.h"
#define MAX_LOADSTRING 100
// Global Variables:
HINSTANCE hInst; // current instance
TCHAR szTitle[MAX_LOADSTRING]; // The title bar text
TCHAR szWindowClass[MAX_LOADSTRING]; // The title bar text
// Foward declarations of functions included in this code module:
ATOM MyRegisterClass(HINSTANCE hInstance);
BOOL InitInstance(HINSTANCE, int);
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK About(HWND, UINT, WPARAM, LPARAM);
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
// TODO: Place code here.
MSG msg;
HACCEL hAccelTable;
// Initialize global strings
LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
LoadString(hInstance, IDC_DD, szWindowClass, MAX_LOADSTRING);
MyRegisterClass(hInstance);
// Perform application initialization:
if (!InitInstance (hInstance, nCmdShow))
{
return FALSE;
}
hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDC_DD);
// Main message loop:
while (GetMessage(msg, NULL, 0, 0))
{
if (!TranslateAccelerator(msg.hwnd, hAccelTable, msg))
{
TranslateMessage(msg);
DispatchMessage(msg);
}
}
return msg.wParam;
}
//
// FUNCTION: MyRegisterClass()
//
// PURPOSE: Registers the window class.
//
// COMMENTS:
//
// This function and its usage is only necessary if you want this code
// to be compatible with Win32 systems prior to the 'RegisterClassEx'
// function that was added to Windows 95. It is important to call this function
// so that the application will get 'well formed' small icons associated
// with it.
//
ATOM MyRegisterClass(HINSTANCE hInstance)
{
WNDCLASSEX wcex;
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = (WNDPROC)WndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInstance;
wcex.hIcon = LoadIcon(hInstance, (LPCTSTR)IDI_DD);
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wcex.lpszMenuName = (LPCSTR)IDC_DD;
wcex.lpszClassName = szWindowClass;
wcex.hIconSm = LoadIcon(wcex.hInstance, (LPCTSTR)IDI_SMALL);
return RegisterClassEx(wcex);
}
//
// FUNCTION: InitInstance(HANDLE, int)
//
// PURPOSE: Saves instance handle and creates main window
//
// COMMENTS:
//
// In this function, we save the instance handle in a global variable and
// create and display the main program window.
//
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
HWND hWnd;
hInst = hInstance; // Store instance handle in our global variable
hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);
if (!hWnd)
{
return FALSE;
}
ShowWindow(hWnd, nCmdShow);
UpdateWindow(hWnd);
return TRUE;
}
//
// FUNCTION: WndProc(HWND, unsigned, WORD, LONG)
//
// PURPOSE: Processes messages for the main window.
//
// WM_COMMAND - process the application menu
// WM_PAINT - Paint the main window
// WM_DESTROY - post a quit message and return
//
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
int wmId, wmEvent;
PAINTSTRUCT ps;
HDC hdc;
TCHAR szHello[MAX_LOADSTRING];
LoadString(hInst, IDS_HELLO, szHello, MAX_LOADSTRING);
switch (message)
{
case WM_COMMAND:
wmId = LOWORD(wParam);
wmEvent = HIWORD(wParam);
// Parse the menu selections:
switch (wmId)
{
case IDM_ABOUT:
DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About);
break;
case IDM_EXIT:
DestroyWindow(hWnd);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
break;
case WM_PAINT:
hdc = BeginPaint(hWnd, ps);
// TODO: Add any drawing code here...
RECT rt;
GetClientRect(hWnd, rt);
DrawText(hdc, szHello, strlen(szHello), rt, DT_CENTER);
EndPaint(hWnd, ps);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}
// Mesage handler for about box.
LRESULT CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_INITDIALOG:
return TRUE;
case WM_COMMAND:
if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
{
EndDialog(hDlg, LOWORD(wParam));
return TRUE;
}
break;
}
return FALSE;
}
Q3: C语言调用API函数
包含api的.h文件,然后直接调用就可以了,比如winsock.h,可以调用recv等
函数
,也可以在函数
前面
加::
答案补充
HWND
hWnd
=
::FindWindow(sClassName,
sWindowName);//传入类明到sClassName,窗口名sWindowName,否则传入NULL
Q4: c语言中怎么调用windowsAPI函数,
比如messagebox()这个API函数在WINDOWS.H文件中
strlen在stdio.h文件中
简单的写一个API
#include "windows.h"
#include "windowsx.h"
WinMain(这里有六个数)
{
MessageBox(NULL,"你好","编程世界",MB_YESNO);
}
Windows 这个多作业系统除了协调应用程序的执行、分配内存、管理资源…之外, 它同时也是一个很大的服务中心,调用这个服务中心的各种服务(每一种服务就是一个函数),可以帮应用程式达到开启视窗、描绘图形、使用周边设备等目的,由于这些函数服务的对象是应用程序(Application), 所以便称之为 Application Programming Interface,简称 API 函数。WIN32 API也就是Microsoft Windows 32位平台的应用程序编程接口。
Q5: c语言api函数
给对话框添加进度条控件,并给进度条控件添加变量,类型为CProgressCtrl,变量名拟为m_Pro
再添加一个按钮控件,改名为确定,双击添加响应函数,添加如下代码:
for(int i=1;i=10;i++)
{
Sleep(100);
m_Pro.SetPos(i*10);
}
然后就行了,具体可以Hi我
关于c语言api函数实例和c语言api怎么用的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。






