Delphi访问共享
var NetSource: TNetResource; Error: LongInt; a: Cardinal; begin with NetSource do begin dwType := RESOURCETYPE_ANY; lpLocalName := 'Z:'; lpRemoteName := '\\192.168.2.4\arc'; lpProvider := ''; end; // case WNetAddConnection3(Handle, NetSour
var
NetSource: TNetResource;
Error: LongInt;
a: Cardinal;
begin
with NetSource do
begin
dwType := RESOURCETYPE_ANY;
lpLocalName := 'Z:';
lpRemoteName := '\\192.168.2.4\arc';
lpProvider := '';
end;
// case WNetAddConnection3(Handle, NetSource, '','', CONNECT_UPDATE_PROFILE) of
//WNetAddConnection3 带有密码输入框 WNetAddConnection2 没有
case WNetAddConnection3(Handle, NetSource, '', '', CONNECT_UPDATE_PROFILE or CONNECT_INTERACTIVE) of
NO_ERROR: ShowMessage('成功') ;
ERROR_ACCESS_DENIED: showmessage('访问被拒绝');
ERROR_ALREADY_ASSIGNED:ShowMessage('设备参数中指定的lpLocalName已经连接。');
ERROR_BAD_DEV_TYPE:ShowMessage('设备类型和资源类型不匹配。');
ERROR_BAD_DEVICE:ShowMessage('在lpLocalName指定的值是无效的');
ERROR_BAD_NET_NAME: ShowMessage('中指定的值lpRemoteName参数无效或无法找到。');
ERROR_BAD_PROFILE :ShowMessage('用户配置文件的格式不正确') ;
ERROR_CANNOT_OPEN_PROFILE :ShowMessage('统无法打开用户配置文件来处理持久连接。');
ERROR_DEVICE_ALREADY_REMEMBERED: ShowMessage('一个条目中指定的设备lpLocalName已经在用户概要。') ;
ERROR_EXTENDED_ERROR:ShowMessage('一个特定于网络错误发生。为了描述的错误,使用WNetGetLastError函数。');
ERROR_INVALID_PASSWORD:ShowMessage('指定的密码是无效的。');
ERROR_NO_NET_OR_BAD_PATH:ShowMessage('操作无法进行,因为不是一个网络组件没有启动或指定的名称不能用。');
ERROR_NO_NETWORK:ShowMessage('网络不存在.');
ERROR_SESSION_CREDENTIAL_CONFLICT: //这里为第二次输入冲突 但是共享文件夹已经可以访问无需密码了,所以这里 不提示
else
ShowMessage('其他意外終止!');
end;
以上,也可以用客户端和服务端 之间通讯传输文件,就不用考虑这么多了
映射网络资源到本地驱动器 网上摘抄
function MapNetworkDrive(const handle : THandle; const uncPath : string) : string;
//returns mapped drive ("z:") on success
//or uncPath on failure / cancel
var
cds : TConnectDlgStruct;
netResource : TNetResource;
begin
result := uncPath;
ZeroMemory(@netResource, SizeOf(TNetResource)) ;
netResource.dwType := RESOURCETYPE_DISK;
netResource.lpRemoteName := PChar(uncPath) ;
cds.cbStructure := SizeOf(TConnectDlgStruct) ;
cds.hwndOwner := handle;
cds.lpConnRes := @netResource;
cds.dwFlags := CONNDLG_PERSIST;
if WNetConnectionDialog1(cds) = NO_ERROR then
begin
result := Chr(-1 + Ord('A') + cds.dwDevNum) + DriveDelim;
end;
end;
使用:MapNetworkDrive(Handle, '')

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

AI Hentai Generator
Generate AI Hentai for free.

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



Users can share the wallpapers they obtain with friends when using WallpaperEngine. Many users do not know how to share WallpaperEngine with friends. They can save their favorite wallpapers locally and then share them with friends through social software. How to share wallpaperengine with friends Answer: Save it locally and share it with friends. 1. It is recommended that you save your favorite wallpapers locally and then share them with friends through social software. 2. You can also upload it to the computer through a folder, and then click Share using the creative workshop function on the computer. 3. Use Wallpaperengine on the computer, open the options bar of the creative workshop and find

More and more enterprises choose to use exclusive enterprise WeChat, which not only facilitates communication between enterprises and customers and partners, but also greatly improves work efficiency. Enterprise WeChat has rich functions, among which the screen sharing function is very popular. During the meeting, by sharing the screen, participants can display content more intuitively and collaborate more efficiently. So how to share your screen efficiently in WeChat Enterprise? For users who don’t know yet, this tutorial guide will give you a detailed introduction. I hope it can help you! How to share screen on WeChat Enterprise? 1. In the blue area on the left side of the main interface of Enterprise WeChat, you can see a list of functions. We find the "Conference" icon. After clicking to enter, three conference modes will appear.

Quick Share can save Samsung users a lot of time transferring files between devices. But Samsung Galaxy users have complained about facing issues with the Quick Share feature on their phones. Typically, visibility issues in quick sharing cause this issue. So, this is the only guide you need to troubleshoot the Quick Share feature on your Galaxy device. Fix 1 – Change Quick Share Visibility Settings Toggle the Quick Share visibility setting on your phone. Quick Share might be set to the wrong settings, causing this issue. Step 1 – First, swipe up once to open the app drawer. Step 2 – Once there, open Settings. Step 3 – Go to the Settings page and open the Connected Devices tab. Step 4 – Turn on the “Quick Share” feature. Step 5

In iOS17, Apple has more control over what apps can see in photos. Read on to learn how to manage app access by app. In iOS, Apple's in-app photo picker lets you share specific photos with the app, while the rest of your photo library remains private. Apps must request access to your entire photo library, and you can choose to grant the following access to apps: Restricted Access – Apps can only see images that you can select, which you can do at any time in the app or by going to Settings > ;Privacy & Security>Photos to view selected images. Full access – App can view photos

A JsonNode is Jackson's JSON tree model that can read JSON into JsonNode instances and write JsonNode into JSON. We can use Jackson to read JSON into a JsonNode by creating an ObjectMapper instance and calling the readValue() method. We can access fields, arrays or nested objects using the get() method of the JsonNode class. We can use the asText() method to return a valid string representation and convert the node's value to Javaint using the asInt() method of the JsonNode class. In the example below we can access Json

In daily life and work, we often need to share files and folders between different devices. Windows 11 system provides convenient built-in folder sharing functions, allowing us to easily and safely share the content we need with others within the same network while protecting the privacy of personal files. This feature makes file sharing simple and efficient without worrying about leaking private information. Through the folder sharing function of Windows 11 system, we can cooperate, communicate and collaborate more conveniently, improving work efficiency and life convenience. In order to successfully configure a shared folder, we first need to meet the following conditions: All devices (participating in sharing) are connected to the same network. Enable Network Discovery and configure sharing. Know the target device

With the launch of the new Apple iPhone15 series mobile phones and the launch of the latest iOS17 mobile operating system, a wealth of new features, adjustments and enhancements have been brought to Apple devices. Users may be wondering how to use the new NameDrop feature on iPhone and iOS17. This guide will provide a brief overview of how to share your contact information quickly and efficiently using the new NameDrop system available on iOS17. NameDrop is a feature that allows iPhone users to quickly share their contact information with others. It's a convenient tool for social events, business meetings or social gatherings where you need to exchange contact details with new friends. However, it's important to note that NameDrop only works for sending new contacts

With the development of the digital era, shared printers have become an indispensable part of the modern office environment. However, sometimes we may encounter the problem that the shared printer cannot be connected to the printer, which will not only affect work efficiency, but also cause a series of troubles. This article aims to explore the reasons and solutions for why a shared printer cannot connect to the printer. There are many reasons why a shared printer cannot connect to the printer, the most common of which is network issues. If the network connection between the shared printer and the printer is unstable or interrupted, normal operation will not be possible.
