⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 username.html

📁 SDK FAQ集
💻 HTML
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"><html lang="en"><head><title>Winsock Programmer's FAQ: Get the Username</title><link rel="Stylesheet" type="text/css" href="../faq.css"></head><body bgcolor="#ffffee" text="#000000" link="#491e00" vlink="#7d2e01" alink="#da7417"><!--  ---- Header Bar ----  --><table border="0" width="95%" bgcolor="#006000" cellpadding="5" cellspacing="3" align="center">	<tr>		<td align="left" bgcolor="#e0e0c0">			<font size="2" face=Verdana,Arial,Helvetica>				<b><a href="../examples/getmac-snmp.html">&lt;&lt;</a></b>			</font>		</td>		<td align="center">			<font face=Verdana,Arial,Helvetica color="#ffffee">				<p align=center class=bigger3><b>				Winsock Programmer's FAQ<br>				Example: How to Get the Username				</b></p>			</font>			</td>		<td align="right" bgcolor="#e0e0c0">			<font size="2" face=Verdana,Arial,Helvetica>				<b><a href="../examples/get-sockets.html">&gt;&gt;</a></b>			</font>		</td>	</tr></table><!--  ---- Body Table ----  --><table width="95%" border="0" cellpadding="10">	<tr valign="top">		<td><p>The Win32 API has a simple function called <code>GetUserName()</code>that works under Windows 95 and Windows NT. The <code>GetUserName()</code>function is very easy to use:</p><hr noshade size=1 color=#404040><h4 class=lmargin><a href="../examples/src/getusername.cpp">getusername.cpp</a></h4><pre><font color="#444444">// Borland C++ 5.0: bcc32.cpp getusername.cpp</font><font color="#444444">// Visual C++ 5.0: cl getusername.cpp advapi32.lib </font><font color="0000ff"><strong>#include <font color="#008000">&lt;iostream.h&gt;</font></strong></font><font color="0000ff"><strong>#include <font color="#008000">&lt;windows.h&gt;</font></strong></font><strong>int</strong> <font color="#2040a0">main</font><font color="4444FF">(</font><font color="4444FF">)</font><font color="4444FF"><strong>{</strong></font>    <strong>char</strong> <font color="#2040a0">acUserName</font><font color="4444FF">[</font><font color="#FF0000">100</font><font color="4444FF">]</font><font color="4444FF">;</font>    <font color="#2040a0">DWORD</font> <font color="#2040a0">nUserName</font> <font color="4444FF">=</font> <strong>sizeof</strong><font color="4444FF">(</font><font color="#2040a0">acUserName</font><font color="4444FF">)</font><font color="4444FF">;</font>    <strong>if</strong> <font color="4444FF">(</font><font color="#2040a0">GetUserName</font><font color="4444FF">(</font><font color="#2040a0">acUserName</font>, <font color="4444FF">&amp;</font><font color="#2040a0">nUserName</font><font color="4444FF">)</font> <font color="4444FF">=</font><font color="4444FF">=</font> <font color="#FF0000">0</font><font color="4444FF">)</font> <font color="4444FF"><strong>{</strong></font>        <font color="#2040a0">cerr</font> <font color="4444FF">&lt;</font><font color="4444FF">&lt;</font> <font color="#008000">&quot;Failed to lookup user name, error code &quot;</font> <font color="4444FF">&lt;</font><font color="4444FF">&lt;</font> <font color="#2040a0">GetLastError</font><font color="4444FF">(</font><font color="4444FF">)</font>            <font color="4444FF">&lt;</font><font color="4444FF">&lt;</font> <font color="#008000">&quot;.&quot;</font> <font color="4444FF">&lt;</font><font color="4444FF">&lt;</font> <font color="#2040a0">endl</font><font color="4444FF">;</font>    <font color="4444FF"><strong>}</strong></font>    <font color="#2040a0">cout</font> <font color="4444FF">&lt;</font><font color="4444FF">&lt;</font> <font color="#008000">&quot;User name is &quot;</font> <font color="4444FF">&lt;</font><font color="4444FF">&lt;</font> <font color="#2040a0">acUserName</font> <font color="4444FF">&lt;</font><font color="4444FF">&lt;</font> <font color="#008000">&quot;.&quot;</font> <font color="4444FF">&lt;</font><font color="4444FF">&lt;</font> <font color="#2040a0">endl</font><font color="4444FF">;</font>    <strong>return</strong> <font color="#FF0000">0</font><font color="4444FF">;</font><font color="4444FF"><strong>}</strong></font></pre>		</td>	</tr></table><!--  ---- Document Footer ----  --><hr noshade size=1 color=#404040><table cellpadding=5 cellspacing=0 border=0 width=95% align=center> 	<tr>		<td align=left>		    <a href="../examples/getmac-snmp.html">&lt;&lt; Get MAC Address</a>		</td>		<td align=right>		    <a href="../examples/get-sockets.html">Maximum Sockets Tester &gt;&gt;</a>		</td>	</tr>	<tr>		<td align=left>			<i>Last modified on 29 April 2000 at 15:52 UTC-7</i>		</td>		<td align=right>			<font size=-1>Please send corrections to <a href="mailto:tangent@cyberport.com">tangent@cyberport.com</a>.</font>		</td>	</tr>	</table>	<table cellpadding=5 cellspacing=0 border=0 width=95% align=center> 	<tr>		<td align=left width=33%>			<font size=-1>				<a href="../index.html"><b>&lt;</b> Go to the main FAQ page</a>			</font>		</td>		<td width=33%>			<font size=-1>			<center>				<a href="http://www.cyberport.com/~tangent/programming"><b>&lt;&lt;</b> Go to my Programming pages</a>			</center>			</font>		</td>		<td align=right width=33%>			<font size=-1>				<a href="http://www.cyberport.com/~tangent/"><b>&lt;&lt;&lt;</b> Go to my Home Page</a>			</font>		</td>	</tr>	</table>	</body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -