C语言如何制作无限弹窗代码?

Python010

C语言如何制作无限弹窗代码?,第1张

方法步骤如下:

1、首先打开计算机,在计算机的桌面上右键点击,选中“文件文档”选项。

2、生成之后,双击打开文件文档。

3、然后在界面内输入如图的代码。

4、输入完毕后,保存起来。

5、然后使用鼠标对文件进行右键,重命名。

6、将txt的后缀,改为vbs格式。

7、双击打开,就可以看见其效果了。这里是关不了的。(ctrl+alt+delete可以停止下来)

直接调用系统API MessageBox()函数就可以了。

函数原形

int WINAPI MessageBox(HWND hWnd,LPCTSTR lpText,LPCTSTR lpCaption,UINT uType)

参数说明

hWnd: 消息框的拥有窗此参数口。如果为NULL,则消息框没有拥有窗口。

lpText:消息框的内容。

lpCaption: 消息框的标题。

uType:

指定一个决定对话框的内容和行为的位标志集。此参数可以为下列标志组中标志的组合。指定下列标志中的一个来显示消息框中的按钮以及图标。

MB_OK 默认值。有一个确认按钮在里面。

MB_YESNO有是和否在里面。

MB_ABORTRETRYIGNORE 有Abort(放弃),Retry(重试)和Ignore(跳过)

MB_YESNOCANCEL 消息框含有三个按钮:Yes,No和Cancel

MB_RETRYCANCEL 有Retry(重试)和Cancel(取消)

MB_OKCANCEL 消息框含有两个按钮:OK和Cancel

当然还有其他标志和返回值, 具体内容参考

https://msdn.microsoft.com/en-us/library/ms645505(VS.85).aspx

最后是用系统API时需要包含头文件 windows.h

#include

#include

char format[]="%s%s\n";

char hello[]="Hello";

char world[]="world";

HWND hwnd;void main(void)

asm

//push NULL

//call dword ptr GetModuleHandle

//mov hwnd,eax push MB_OK mov eax,offset world push eax mov eax,offset hello push eax push 0//说明此处不能将前面注释掉代码处得到的hwnd压栈,否则对话框弹不出来。

call dword ptr MessageBox

}

}

WINDOWS程序MessagBox

WINDOWS或控制台 assert

C/C++ code

// crt_assert.c

// compile with: /c

#include <stdio.h>

#include <assert.h>

#include <string.h>

void analyze_string( char *string )   // Prototype

int main( void )

{

char  test1[] = "abc", *test2 = NULL, test3[] = ""

printf ( "Analyzing string '%s'\n", test1 )fflush( stdout )

analyze_string( test1 )

printf ( "Analyzing string '%s'\n", test2 )fflush( stdout )

analyze_string( test2 )

printf ( "Analyzing string '%s'\n", test3 )fflush( stdout )

analyze_string( test3 )

}

// Tests a string to see if it is NULL,

// empty, or longer than 0 characters.

void analyze_string( char * string )

{

assert( string != NULL )        // Cannot be NULL

assert( *string != '\0' )       // Cannot be empty

assert( strlen( string ) >2 )  // Length must exceed 2

}

扩展资料:

#include <windows.h>

#include <Commdlg.h>

#include <stdio.h>

// 返回值: 成功 1, 失败 0

// 通过 path 返回获取的路径

int FileDialog(char *path)

{

OPENFILENAME ofn

ZeroMemory(&ofn, sizeof(ofn))

ofn.lStructSize = sizeof(ofn)// 结构大小

ofn.lpstrFile = path// 路径

ofn.nMaxFile = MAX_PATH// 路径大小

ofn.lpstrFilter = "All\0*.*\0Text\0*.TXT\0"// 文件类型

ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST

return GetOpenFileName(&ofn)

}

int main(char argc, char *argv[])

{

char szFile[MAX_PATH] = {0}

if(FileDialog(szFile))

{

puts(szFile)

}

getchar()

return 0

}