using windows api functions

yidabu yidabu.nospam at gmail.com
Wed May 2 03:54:50 PDT 2007


lee Wrote:

> I'm trying to call the OpenProcess() api function. I included std.c.windows.windows at the beginning of the file, but the compiler still does not recognize the function name. The function is defined in kernel32.dll . what am I doing wrong? 

you can call any window api like this:
import std.c.windows.windows;	//for WinExec
import std.windows.charset;	//for toMBSz

void main()
{
	// bbs.yidabu.com 注toMBSz函数是为了生成null结尾字符串
	LPCSTR lpCmdLine = toMBSz(r"C:\Program Files\Internet Explorer\iexplore.exe http://bbs.yidabu.com/forum-10-1.html");
	UINT uCmdShow = SW_SHOWMAXIMIZED;
	WinExec(lpCmdLine,uCmdShow);
}

// bbs.yidabu.com 下面就是定义要调用的windows api函数
extern (Windows)
{
	export {
		UINT WinExec(LPCSTR lpCmdLine,UINT uCmdShow);
	}
}



More information about the Digitalmars-d-learn mailing list