Tag: windows

如何在Turbo C IDE中查看程序的输出?

如何在C中打印#include #include #include void main() { printf(“#include”); } 如何获得输出 #include 你必须把getch(); 然后按Ctrl + f9而不是alt + f5

打开外部程序

我一直试图在C中打开像编辑器这样的外部程序。我已经搜索了几个小时但没有找到打开外部可执行文件的方法,例如从控制台应用程序打开Skype等。 到目前为止这是我的代码: /* fopen1.c */ #include #include #include #include int main(int) { FILE *fp; fp = fopen(“C://Users/Jonte/Desktop/Skype.exe”, “r”); } 如何打开外部文件? 谢谢,真诚的,贝林

在C中连接Postgresql

我正在尝试将在Windows上运行的C脚本连接到Postgresql数据库。 目前,我在网站上获得了这个脚本: #include #include “libpq-fe.h” #include #include int main() { PGconn *conn; PGresult *res; int rec_count; int row; int col; conn = PQconnectdb(“dbname=ljdata host=localhost user=dataman password=supersecret”); if (PQstatus(conn) == CONNECTION_BAD) { puts(“We were unable to connect to the database”); exit(0); } res = PQexec(conn, “update people set phonenumber=\’5055559999\’ where id=3”); res = PQexec(conn, “select lastname,firstname,phonenumber […]

灰度图像转换.img到.ras – 在Windows中的白色和蓝色的灰度等级?! C

我想将.img文件(512字节标题,512×512像素,每像素8位(值:0-255))转换为.ras文件。 为此,我在本文末尾得到了C代码。 我的测试图像(test.img)的输出应该是黑/白图像 – 所以只包含0或255的值。但问题是,当我在Windows中编译C代码(从底部)时,我的结果。 ras文件是白色还是亮蓝色?! 奇怪的是。 当我在Linux中编译C代码时,结果是完全黑/白?! 这怎么来的? 在两个系统中我使用了64位。 所以你可以尝试一下:1。用以下代码编译C代码:gcc -lm img2ras.c -o img2ras 2.通过控制台将.img转换为.ras:img2ras test.img test.ras 3.在gimp中观察.ras文件,XnView或PaintshopPro 你是否有任何线索如何在具有相同版本的gcc 4.8.1的不同操作系统上发生这种尴尬的结果? test.img: http : //www.file-upload.net/download-8629102/test.img.html img2ras.c /* this program accepts an input file (which comes from the image capturing board) and an output file, which must be specified on the command line. The output file […]

限制用户停止Windows服务

我参与编写Windows服务。 在我开始写作之前,我想知道 在LOGIN USERS方面要考虑哪些要点,特别是如何限制其他用户“停止服务”? 在编写服务时我应该考虑哪些通用点? 一旦用户尝试停止服务,如何显示警告提示? 注意:我正在尝试用C编写服务。 谢谢。

在c-compile期间使用luarocks为lua安装yaml的问题

我有lua,我使用了luarocks。 编辑:在Windows系统上 我从v202-3这里下载了luasocket-2.0.2-3.win32-x86.rock文件,成功安装了luasocket。 它是一个旧版本,但它的工作原理。 但是现在我需要安装yaml所以我可以使用yaml文件。 现在我被迫使用* .src.rock文件或.rockspec文件进行安装。 我试过了: luarocks install yaml ,它给出: D:\user\workspace\_lua>luarocks install yaml Warning: Failed searching manifest: Failed fetching manifest for https://luarocks.org – Failed downloading https://luarocks.org/manifest – C:\Users\user\AppData\Local/LuaRocks/Cache/https___luarocks.org/manifest Warning: Failed searching manifest: Failed fetching manifest for https://raw.githubusercontent.com/rocks-moonscript-org/moonrocks-mirror/master/ – Failed downloading https://raw.githubusercontent.com/rocks-moonscript-org/moonrocks-mirror/master/manifest – C:\Users\user\AppData\Local/LuaRocks/Cache/https___raw.githubusercontent.com_rocks-moonscript-org_moonrocks-mirror_master_/manifest Warning: Failed searching manifest: Failed fetching manifest for http://luafr.org/moonrocks/ – […]

使用C ++导入注册表文件

我有一些问题,让以下简单的代码正确运行: #include int main( void ) { system(“foo.reg”); //why does this NOT WORK?! //system(“reg import foo.reg”); //why does this NOT WORK?! //system(“regedit \”foo.reg\””); //why does this NOT WORK?! return 0; } 注册表文件位于已编译的可执行文件所在的目录中。 当我从命令行运行它时, foo.reg运行成功,但运行上面的程序只显示regedit确认窗口,并且在注册表本身没有相应的更改。 我使用Dev-C ++编写程序,我运行的是Windows XP x64 SP2。 任何帮助将不胜感激。

使用stdprn时的C编译错误

我的操作系统是:Windows 8 IDE:VS 2012 这是我的C程序。 (来自书) /* print_it.c—This program prints a listing with line numbers! */ #include #include void do_heading(char *filename); int line = 0, page = 0; int main( int argv, char *argc[] ) { char buffer[256]; FILE *fp; if( argv 1) fprintf( stdprn, “\f” ); fprintf( stdprn, “Page: %d, %s\n\n”, page, filename ); […]

重定向CMD.exe输出并通过管道输入c

我试图打印输出和输入cmd命令收到stdout就像普通的cmd.exe一样。 我可以使用函数_popen但是当我启动像Python或Powershell这样的程序时,它不起作用。 所以我需要输出子进程并能够向子进程发送命令。 这里有一个类似的问题 所以我修改了这个链接的代码,如下所示: void WriteToPipe(char* command){ DWORD dwRead, dwWritten; BOOL bSuccess = FALSE; bSuccess = WriteFile(g_hChildStd_IN_Wr, command, strlen(command), &dwWritten, NULL); // Close the pipe handle so the child process stops reading. if (!CloseHandle(g_hChildStd_IN_Wr)) ErrorExit(TEXT(“StdInWr CloseHandle”)); } void ReadFromPipe(void){ DWORD dwRead, dwWritten; CHAR chBuf[BUFSIZE]; BOOL bSuccess = FALSE; HANDLE hParentStdOut = GetStdHandle(STD_OUTPUT_HANDLE); bSuccess = […]

GetThreadTimes如何报告hibernate时间?

我目前正在使用GetThreadTimes告诉我在应用程序的事件循环中花了多少时间。 我想知道这会如何受到冬眠的影响。 是否报告了hibernate时间? 或者也许是系统时间? 所有版本的Windows上的行为是否相同? 注意我在这里问了Posix的相同问题。