应用程序重起自身等几则技巧
http://blog.csdn.net/absurd 作者联系方式: Li XianJing xianjimli at hotmail dot com 更新时间: 2006-12-19 1. 应用程序重起自身。 以前开发一个服务器软件,当通过客户端工具修改某些设置后,服务器要重新重动自己。当时竟想不出什么好办法,只好开了
http://blog.csdn.net/absurd
作者联系方式:Li XianJing
更新时间:2006-12-19
1. 应用程序重起自身。
以前开发一个服务器软件,当通过客户端工具修改某些设置后,服务器要重新重动自己。当时竟想不出什么好办法,只好开了两个进程,子进程为工作进程,父进程为监视进程,子进程退出时,父进程再重起子进程。今天在busybox里发现一种最简单的重起方法:
intmain(intargc, char* argv[]) { sleep(2);
printf("%s %s/n", argv[0], argv[1]); fflush(stdout);
execv(argv[0], argv);
return 0; } |
2. 用printf打印long long整数。
几天前为了用printf打印出long long的整数,不得不去查看glibc的源代码,这里记个笔记吧。
#include stdio.h>
intmain(intargc, charargv[]) { longlongval = 0;
sscanf("0x1122334455667788", "0x%Lx", &val); printf("val = 0x%Lx/n", val);
sscanf("1122334455667788", "%Ld", &val); printf("val = %Ld/n", val);
return 0; } |
3. Win32的电源管理函数。
前段时间在研究linux下的电源管理,本来想看看win32下的电源管理,一直没有时间。今天群里有网友问Win32下如何让系统休眠,在MSDN里查了一下,找到了一个电源管理函数,记在这里吧,有时间再看看相关资料。
BOOLSetSystemPowerState( BOOLfSuspend, // system state BOOLfForce // forced suspension option ); Windows NT/2000: Requires Windows 2000. Windows 95/98: Requires Windows 95 or later. Header: Declared in Winbase.h; include Windows.h. Library: Use Kernel32.lib. |
~~end~~

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

The Apple Vision Pro headset is not natively compatible with computers, so you must configure it to connect to a Windows computer. Since its launch, Apple Vision Pro has been a hit, and with its cutting-edge features and extensive operability, it's easy to see why. Although you can make some adjustments to it to suit your PC, and its functionality depends heavily on AppleOS, so its functionality will be limited. How do I connect AppleVisionPro to my computer? 1. Verify system requirements You need the latest version of Windows 11 (Custom PCs and Surface devices are not supported) Support 64-bit 2GHZ or faster fast processor High-performance GPU, most

Having issues with the Shazam app on iPhone? Shazam helps you find songs by listening to them. However, if Shazam isn't working properly or doesn't recognize the song, you'll have to troubleshoot it manually. Repairing the Shazam app won't take long. So, without wasting any more time, follow the steps below to resolve issues with Shazam app. Fix 1 – Disable Bold Text Feature Bold text on iPhone may be the reason why Shazam is not working properly. Step 1 – You can only do this from your iPhone settings. So, open it. Step 2 – Next, open the “Display & Brightness” settings there. Step 3 – If you find that “Bold Text” is enabled

Win11 Tips Sharing: One trick to skip Microsoft account login Windows 11 is the latest operating system launched by Microsoft, with a new design style and many practical functions. However, for some users, having to log in to their Microsoft account every time they boot up the system can be a bit annoying. If you are one of them, you might as well try the following tips, which will allow you to skip logging in with a Microsoft account and enter the desktop interface directly. First, we need to create a local account in the system to log in instead of a Microsoft account. The advantage of doing this is

While studying in high school, some students take very clear and accurate notes, taking more notes than others in the same class. For some, note-taking is a hobby, while for others, it is a necessity when they easily forget small information about anything important. Microsoft's NTFS application is particularly useful for students who wish to save important notes beyond regular lectures. In this article, we will describe the installation of Ubuntu applications on Ubuntu24. Updating the Ubuntu System Before installing the Ubuntu installer, on Ubuntu24 we need to ensure that the newly configured system has been updated. We can use the most famous "a" in Ubuntu system

In C language, it represents a pointer, which stores the address of other variables; & represents the address operator, which returns the memory address of a variable. Tips for using pointers include defining pointers, dereferencing pointers, and ensuring that pointers point to valid addresses; tips for using address operators & include obtaining variable addresses, and returning the address of the first element of the array when obtaining the address of an array element. A practical example demonstrating the use of pointer and address operators to reverse a string.

We often create and edit tables in excel, but as a novice who has just come into contact with the software, how to use excel to create tables is not as easy as it is for us. Below, we will conduct some drills on some steps of table creation that novices, that is, beginners, need to master. We hope it will be helpful to those in need. A sample form for beginners is shown below: Let’s see how to complete it! 1. There are two methods to create a new excel document. You can right-click the mouse on a blank location on the [Desktop] - [New] - [xls] file. You can also [Start]-[All Programs]-[Microsoft Office]-[Microsoft Excel 20**] 2. Double-click our new ex

VSCode (Visual Studio Code) is an open source code editor developed by Microsoft. It has powerful functions and rich plug-in support, making it one of the preferred tools for developers. This article will provide an introductory guide for beginners to help them quickly master the skills of using VSCode. In this article, we will introduce how to install VSCode, basic editing operations, shortcut keys, plug-in installation, etc., and provide readers with specific code examples. 1. Install VSCode first, we need

Title: PHP Programming Tips: How to Jump to a Web Page within 3 Seconds In web development, we often encounter situations where we need to automatically jump to another page within a certain period of time. This article will introduce how to use PHP to implement programming techniques to jump to a page within 3 seconds, and provide specific code examples. First of all, the basic principle of page jump is realized through the Location field in the HTTP response header. By setting this field, the browser can automatically jump to the specified page. Below is a simple example demonstrating how to use P
