<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress.com" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>

<channel>
	<title>net_api_status &amp;laquo; WordPress.com Tag Feed</title>
	<link>http://en.wordpress.com/tag/net_api_status/</link>
	<description>Feed of posts on WordPress.com tagged "net_api_status"</description>
	<pubDate>Sun, 19 May 2013 00:16:55 +0000</pubDate>

	<generator>http://en.wordpress.com/tags/</generator>
	<language>en</language>

<item>
<title><![CDATA[How to create a Shared Folder]]></title>
<link>http://vcpptips.wordpress.com/2012/01/28/how-to-create-a-shared-folder/</link>
<pubDate>Sat, 28 Jan 2012 05:01:39 +0000</pubDate>
<dc:creator>Sanoop S P</dc:creator>
<guid>http://vcpptips.wordpress.com/2012/01/28/how-to-create-a-shared-folder/</guid>
<description><![CDATA[If you are writing an installation program, generally you may need to create number of folders in th]]></description>
<content:encoded><![CDATA[<p style="text-align:left;"><a href="http://vcpptips.files.wordpress.com/2012/01/description.jpg"><img class="alignnone size-full wp-image-1059" title="description" src="http://vcpptips.files.wordpress.com/2012/01/description.jpg?w=233&#038;h=88" alt="" width="233" height="88" /></a></p>
<p style="text-align:left;">If you are writing an <span style="color:#0000ff;">installation program</span>, generally you may need to create number of folders in the user’s machine and some of them may be<span style="color:#0000ff;"> shared over the network</span>.</p>
<p style="text-align:left;"><a href="http://vcpptips.files.wordpress.com/2012/01/howcanidoit_2011.jpg"><img class="alignnone size-full wp-image-1060" title="howcanidoit_2011" src="http://vcpptips.files.wordpress.com/2012/01/howcanidoit_2011.jpg?w=306&#038;h=88" alt="" width="306" height="88" /></a></p>
<p style="text-align:left;">To establish this <span style="color:#0000ff;">Windows</span> provide an <span style="color:#0000ff;">API</span> <span style="color:#0000ff;">NetShareAdd</span>, which share folders over the network. The 3rd parameter (<span style="color:#0000ff;">SHARE_INFO_2</span>) of this function holds the information about the shared folder.</p>
<p>Here the function<span style="color:#0000ff;"> _wmkdir</span> is used to create a <span style="color:#0000ff;">shared directory</span>. Once it successfully created, we can share the same. If the folder is already existed, it returns -1.</p>
<p style="text-align:left;"><span style="font-family:Consolas, Monaco, 'Courier New', Courier, monospace;line-height:18px;font-size:12px;white-space:pre;"> <a href="http://vcpptips.files.wordpress.com/2012/01/codesnippet_2011.jpg"><img class="alignnone size-full wp-image-1061" title="codesnippet_2011" src="http://vcpptips.files.wordpress.com/2012/01/codesnippet_2011.jpg?w=249&#038;h=88" alt="" width="249" height="88" /></a></span><span style="font-family:Consolas, Monaco, 'Courier New', Courier, monospace;font-size:12px;line-height:18px;white-space:pre;"> </span></p>
<pre>void CreateSharedFolder()
{
	CString SHARED_FOLDER_PATH = _T("C:\\SharedFolder");

	/* Create a new directory */
	_wmkdir(SHARED_FOLDER_PATH);

	NET_API_STATUS res;
	SHARE_INFO_2 p;
	DWORD parm_err = 0;

	/* Fill in the SHARE_INFO_2 structure. */

	//Shared folder name
	p.shi2_netname		= _T("TestShare");
	// disk drive
	p.shi2_type			= STYPE_DISKTREE;
	//comment about shared folder
	p.shi2_remark		= _T("My Shared Folder");
	// share-level security
	p.shi2_permissions	= ACCESS_READ;
	//max no of connections that the shared folder can accommodate
	p.shi2_max_uses		= 4;
	p.shi2_current_uses = 0;
	// local path for the shared folder
	p.shi2_path = SHARED_FOLDER_PATH.GetBuffer(SHARED_FOLDER_PATH.GetLength());
	// no password
	p.shi2_passwd		= NULL; 

	SHARED_FOLDER_PATH.ReleaseBuffer();

	/* Share the folder. */
	res=NetShareAdd(NULL, 2, (LPBYTE) &#38;p, &#38;parm_err);

	/* Check whether its succeeded or not. */
	if(res==0)
		AfxMessageBox(_T("SUCCEEDED"));
	else
		AfxMessageBox(_T("FAILED"));
}</pre>
<div></div>
<p style="text-align:left;"><a href="http://vcpptips.files.wordpress.com/2012/01/note_2011.jpg"><img class="alignnone size-full wp-image-1067" title="note_2011" src="http://vcpptips.files.wordpress.com/2012/01/note_2011.jpg?w=140&#038;h=88" alt="" width="140" height="88" /></a></p>
<p style="text-align:left;">Don’t forget to include the header files<span style="color:#0000ff;"> lm.h</span> and <span style="color:#0000ff;">direct.h</span> for the functions NetShareAdd and _wmkdir respectively. Also include the <span style="color:#0000ff;">Netapi32.lib</span> too…</p>
]]></content:encoded>
</item>

</channel>
</rss>
