如何从Cygwin程序调用Win32 API [英] How do I call the Win32 API from a Cygwin program

查看:61
本文介绍了如何从Cygwin程序调用Win32 API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找正在使用的项目中使用Win32 API.但是我不知道如何从我的cygwin项目中调用Win32 API.有人可以指出我正确的方向吗?

I'm looking to use the Win32 API in a project I'm working on. However I have no idea how to call the Win32 API from my cygwin project. Can someone point me in the correct direction?

推荐答案

可以通过cygwin程序通过包含"windows.h"头文件来访问Win32 API.当然,这意味着您已经安装了win32软件包.这是一个示例程序:

The Win32 API can be accessed from a cygwin program by including the "windows.h" header file. It implies that you have the win32 packages installed, of course. Here is an example program:

#include <iostream>
#include <string>
#include <windows.h>

int main(int argc, char *argv[])
{
    std::string val;

    if (argc > 1)
    {
        val = argv[1];
    }

    std::cout << "You typed: " << val << std::endl;
    ::MessageBox(NULL, val.c_str(), "You Typed:", MB_OK);

    return 0;
}

这可以编译并与"make filename"链接,其中filename.cpp包含上述源.然后在bash提示符下键入./filename xxxx来执行.然后xxxx将出现在消息框窗口中.

This can be compiled and linked with "make filename" where filename.cpp contains the above source. Then execute by typing ./filename xxxx at the bash prompt. Then xxxx will appear in a message box window.

这篇关于如何从Cygwin程序调用Win32 API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆