如何复制一个文件到用户的桌面上,如何实现?

lisen101 2003-10-18 05:07:27
FillCopy ——到是容易,可是如何得到Win98或是2000用户的桌面的路径呢?

或是利用别的什么方法?

...全文
372 15 打赏 收藏 转发到动态 举报
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
rainstormmaster 2003-10-19
  • 打赏
  • 举报
回复
to goodname008(卢培培,LPP Software) :
这是试出来的,希望对你有用

CSIDL_DESKTOP这样的常数值为: 0时,获得路径为: C:\WINDOWS\Desktop
CSIDL_DESKTOP这样的常数值为: 1时,获得路径为:
CSIDL_DESKTOP这样的常数值为: 2时,获得路径为: C:\WINDOWS\Start Menu\Programs
CSIDL_DESKTOP这样的常数值为: 3时,获得路径为:
CSIDL_DESKTOP这样的常数值为: 4时,获得路径为:
CSIDL_DESKTOP这样的常数值为: 5时,获得路径为: C:\My Documents
CSIDL_DESKTOP这样的常数值为: 6时,获得路径为: C:\WINDOWS\Favorites
CSIDL_DESKTOP这样的常数值为: 7时,获得路径为: C:\WINDOWS\Start Menu\Programs\启动
CSIDL_DESKTOP这样的常数值为: 8时,获得路径为: C:\WINDOWS\Recent
CSIDL_DESKTOP这样的常数值为: 9时,获得路径为: C:\WINDOWS\SendTo
CSIDL_DESKTOP这样的常数值为: 10时,获得路径为:
CSIDL_DESKTOP这样的常数值为: 11时,获得路径为: C:\WINDOWS\Start Menu
CSIDL_DESKTOP这样的常数值为: 12时,获得路径为:
CSIDL_DESKTOP这样的常数值为: 13时,获得路径为:
CSIDL_DESKTOP这样的常数值为: 14时,获得路径为:
CSIDL_DESKTOP这样的常数值为: 15时,获得路径为:
CSIDL_DESKTOP这样的常数值为: 16时,获得路径为: C:\WINDOWS\Desktop
CSIDL_DESKTOP这样的常数值为: 17时,获得路径为:
CSIDL_DESKTOP这样的常数值为: 18时,获得路径为:
CSIDL_DESKTOP这样的常数值为: 19时,获得路径为: C:\WINDOWS\NetHood
CSIDL_DESKTOP这样的常数值为: 20时,获得路径为: C:\WINDOWS\FONTS
CSIDL_DESKTOP这样的常数值为: 21时,获得路径为: C:\WINDOWS\ShellNew
CSIDL_DESKTOP这样的常数值为: 22时,获得路径为:
CSIDL_DESKTOP这样的常数值为: 23时,获得路径为: C:\WINDOWS\All Users\Start Menu\Programs
CSIDL_DESKTOP这样的常数值为: 24时,获得路径为:
CSIDL_DESKTOP这样的常数值为: 25时,获得路径为: C:\WINDOWS\All Users\Desktop
CSIDL_DESKTOP这样的常数值为: 26时,获得路径为: C:\WINDOWS\Application Data
CSIDL_DESKTOP这样的常数值为: 27时,获得路径为: C:\WINDOWS\PrintHood
CSIDL_DESKTOP这样的常数值为: 28时,获得路径为: C:\WINDOWS\Local Settings\Application Data
CSIDL_DESKTOP这样的常数值为: 29时,获得路径为:
CSIDL_DESKTOP这样的常数值为: 30时,获得路径为:
CSIDL_DESKTOP这样的常数值为: 31时,获得路径为:
CSIDL_DESKTOP这样的常数值为: 32时,获得路径为: C:\WINDOWS\Temporary Internet Files
CSIDL_DESKTOP这样的常数值为: 33时,获得路径为: C:\WINDOWS\Cookies
CSIDL_DESKTOP这样的常数值为: 34时,获得路径为: C:\WINDOWS\History
CSIDL_DESKTOP这样的常数值为: 35时,获得路径为: C:\WINDOWS\All Users\Application Data
CSIDL_DESKTOP这样的常数值为: 36时,获得路径为: C:\WINDOWS
CSIDL_DESKTOP这样的常数值为: 37时,获得路径为: C:\WINDOWS\SYSTEM
CSIDL_DESKTOP这样的常数值为: 38时,获得路径为: C:\Program Files
CSIDL_DESKTOP这样的常数值为: 39时,获得路径为: C:\My Documents\My Pictures
CSIDL_DESKTOP这样的常数值为: 40时,获得路径为:
CSIDL_DESKTOP这样的常数值为: 41时,获得路径为:
CSIDL_DESKTOP这样的常数值为: 42时,获得路径为:
CSIDL_DESKTOP这样的常数值为: 43时,获得路径为: C:\Program Files\Common Files
lisen101 2003-10-19
  • 打赏
  • 举报
回复
感谢关注!一定加分!等我试试
goodname008 2003-10-19
  • 打赏
  • 举报
回复
to rainstormmaster:
能不能多透露点像这样的常量,或者有链接也行。
Private Const CSIDL_DESKTOP = &H0
Private Const SHGFP_TYPE_CURRENT = &H0
goodname008 2003-10-19
  • 打赏
  • 举报
回复
rainstormmaster的方法好,楼主试试。
goodname008 2003-10-19
  • 打赏
  • 举报
回复
to bigpig(春天的国度):

GetVersionEx

VB声明
Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" (ByVal lpVersionInformation As OSVERSIONINFO) As Long
说明
在一个OSVERSIONINFO结构中载入与平台和操作系统有关的版本信息
返回值
Long,非零表示成功,零表示失败
参数表
参数 类型及说明
lpVersionInformation OSVERSIONINFO,用于装载版本信息的结构。在正式调用函数之前,必须先将这个结构的dwOSVersionInfoSize字段设为结构的大小(148)



OSVERSIONINFO

类型定义
Type OSVERSIONINFO ' 148 Bytes
dwOSVersionInfoSize As Long
dwMajorVersion As Long
dwMinorVersion As Long
dwBuildNumber As Long
dwPlatformId As Long
szCSDVersion As String * 128
End Type
说明
This structure contains operating system version information. This structure is used with the GetVersionEx function.

字段表
字段 类型与说明
dwOSVersionInfoSize Long,Size of this data structure, currently at 148 bytes. This field must be set before calling the GetVersionEx function.
dwMajorVersion Long,Specifies the major and minor version number of the operating system.
dwMinorVersion
dwBuildNumber Long,Specifies the build number of the operating system. On Windows 95, build 1000 respresents OEM service release #2.
dwPlatformId Long,Specifies the platform supported by the operating system. May be one of the following:VER_PLATFORM_WIN32s: Win32s on Windows 3.1.VER_PLATFORM_WIN32_WINDOWS: Win32 on Windows 95.VER_PLATFORM_WIN32_NT: Windows NT.
szCSDVersion String,Contains additional information about the operating system



MSDN:

GetVersionEx
The GetVersionEx function obtains extended information about the version of the operating system that is currently running.

BOOL GetVersionEx(
LPOSVERSIONINFO lpVersionInformation // pointer to version
// information structure
);

Parameters
lpVersionInformation
Pointer to an OSVERSIONINFO data structure that the function fills with operating system version information.
Before calling the GetVersionEx function, set the dwOSVersionInfoSize member of the OSVERSIONINFO data structure to sizeof(OSVERSIONINFO).

Windows NT 5.0 and later: This member can be a pointer to an OSVERSIONINFOEX structure. Set the dwOSVersionInfoSize member to sizeof(OSVERSIONINFOEX) to identify the type of structure.

Return Values
If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero. To get extended error information, callGetLastError. The function fails if you specify an invalid value for the dwOSVersionInfoSize member of the OSVERSIONINFO or OSVERSIONINFOEX structure.

Remarks
When using the GetVersionEx function to determine whether your application is running on a particular version of the operating system, check for version numbers that are greater than or equal to the desired version numbers. This ensures that the test succeeds for later versions of the operating system. For example, if your application requires Windows 98, use the following test:

GetVersionEx (&osvi);
bIsWindows98orLater =
(osvi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) &&
( (osvi.dwMajorVersion > 4) ||
( (osvi.dwMajorVersion == 4) && (osvi.dwMinorVersion > 0) ) );

Identifying the current operating system is usually not the best way to determine whether a particular operating system feature is present. This is because the operating system may have had new features added in a redistributable DLL. Rather than using GetVersionEx to determine the operating system platform or version number, test for the presence of the feature itself.

To determine the best way to test for a feature, refer to the documentation for the feature of interest. The following list discusses some common techniques for feature detection:

You can test for the presence of the functions associated with a feature. To test for the presence of a function in a system DLL, call theLoadLibrary function to load the DLL. Then call theGetProcAddress function to determine whether the function of interest is present in the DLL. Use the pointer returned by GetProcAddress to call the function. Note that even if the function is present, it may be a stub that just returns an error code such as ERROR_CALL_NOT_IMPLEMENTED.
You can determine the presence of some features by using the GetSystemMetrics function. For example, you can detect multiple display monitors by calling GetSystemMetrics(SM_CMONITORS).
There are several versions of the redistributable DLLs that implement shell and common control features. For information about determining which versions are present on the system your application is running on, see the topicShell Versions.
Windows CE: The value of the dwPlatformID member of the OSVERSIONINFO structure will be VER_PLATFORM_WIN32_CE.

QuickInfo
Windows NT: Requires version 3.5 or later.
Windows: Requires Windows 95 or later.
Windows CE: Requires version 1.0 or later.
Header: Declared in winbase.h.
Import Library: Use kernel32.lib.
Unicode: Implemented as Unicode and ANSI versions on Windows NT.



OSVERSIONINFO
The OSVERSIONINFO data structure contains operating system version information. The information includes major and minor version numbers, a build number, a platform identifier, and descriptive text about the operating system. This structure is used with the GetVersionEx function.

typedef struct _OSVERSIONINFO{
DWORD dwOSVersionInfoSize;
DWORD dwMajorVersion;
DWORD dwMinorVersion;
DWORD dwBuildNumber;
DWORD dwPlatformId;
TCHAR szCSDVersion[ 128 ];
} OSVERSIONINFO;

Members
dwOSVersionInfoSize
Specifies the size, in bytes, of this data structure. Set this member to sizeof(OSVERSIONINFO) before calling the GetVersionEx function.
dwMajorVersion
Identifies the major version number of the operating system. For example, for Windows NT version 3.51, the major version number is 3; and for Windows NT version 4.0, the major version number is 4.
dwMinorVersion
Identifies the minor version number of the operating system. For example, for Windows NT version 3.51, the minor version number is 51; and for Windows NT version 4.0, the minor version number is 0.
dwBuildNumber
Windows NT: Identifies the build number of the operating system.
Windows 95: Identifies the build number of the operating system in the low-order word. The high-order word contains the major and minor version numbers.

dwPlatformId
Identifies the operating system platform. This member can be one of the following values: Value Platform
VER_PLATFORM_WIN32s Win32s on Windows 3.1.
VER_PLATFORM_WIN32_WINDOWS Win32 on Windows 95 or Windows 98.
For Windows 95, dwMinorVersion is zero.

For Windows 98, dwMinorVersion is greater than zero.

VER_PLATFORM_WIN32_NT Win32 on Windows NT.



szCSDVersion
Windows NT: Contains a null-terminated string, such as "Service Pack 3", that indicates the latest Service Pack installed on the system. If no Service Pack has been installed, the string is empty.
Windows 95: Contains a null-terminated string that provides arbitrary additional information about the operating system.

QuickInfo
Windows NT: Requires version 3.5 or later.
Windows: Requires Windows 95 or later.
Windows CE: Requires version 1.0 or later.
Header: Declared in winbase.h.
Unicode: Defined as Unicode and ANSI structures.

bigpig 2003-10-19
  • 打赏
  • 举报
回复
goodname008(卢培培,LPP Software) :
如果我想得到操作系统的具体版本,或者比如win2000+补丁号,可以实现吗?该怎么做?
rainstormmaster 2003-10-19
  • 打赏
  • 举报
回复
goodname008(卢培培,LPP Software)的方法太麻烦了
试试这个:
Private Declare Function SHGetFolderPath Lib "shfolder.dll" Alias "SHGetFolderPathA" (ByVal hwndOwner As Long, _
ByVal nFolder As Long, ByVal hToken As Long, ByVal dwReserved As Long, ByVal lpszPath As String) As Long
Private Declare Function GetDesktopWindow Lib "user32" () As Long
Private Const CSIDL_DESKTOP = &H0
Private Const SHGFP_TYPE_CURRENT = &H0
Function GetMyFolderPath() As String
Dim sBuf As String
sBuf = Space$(255)
SHGetFolderPath GetDesktopWindow, CSIDL_DESKTOP, 0&, SHGFP_TYPE_CURRENT, sBuf
sBuf = Trim$(sBuf)
sBuf = Left$(sBuf, Len(sBuf) - 1)
GetMyFolderPath = sBuf
End Function


Private Sub Command1_Click()
Dim X As String
X = GetMyFolderPath
MsgBox X
End Sub
goodname008 2003-10-19
  • 打赏
  • 举报
回复
http://expert.csdn.net/Expert/FAQ/FAQ_Index.asp?id=172326

' 先在窗体中加一个Command,然后把上面的代码拷贝到窗体模块中
' 单击按钮就会出现对话框显示操作系统的名称。

Option Explicit
Private Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" (lpVersionInformation As OSVERSIONINFO) As Long
Private Type OSVERSIONINFO
dwOSVersionInfoSize As Long
dwMajorVersion As Long
dwMinorVersion As Long
dwBuildNumber As Long
dwPlatformId As Long
szCSDVersion As String * 128 ' Maintenance string for PSS usage
osName As String ' 我自己加的, 操作系统的名称
End Type

Private Sub Command1_Click()
Dim v As OSVERSIONINFO
v = GetWindowsVersion()
MsgBox v.osName
End Sub

' 获得 Windows 操作系统的版本
' OSVERSIONINFO 结构中的 osName 返回操作系统的名称
Private Function GetWindowsVersion() As OSVERSIONINFO
Dim ver As OSVERSIONINFO
ver.dwOSVersionInfoSize = 148
GetVersionEx ver
With ver
Select Case .dwPlatformId
Case 1
Select Case .dwMinorVersion
Case 0
.osName = "Windows 95"
Case 10
.osName = "Windows 98"
Case 90
.osName = "Windows Mellinnium"
End Select
Case 2
Select Case .dwMajorVersion
Case 3
.osName = "Windows NT 3.51"
Case 4
.osName = "Windows NT 4.0"
Case 5
If .dwMinorVersion = 0 Then
.osName = "Windows 2000"
Else
.osName = "Windows XP"
End If
End Select
Case Else
.osName = "Failed"
End Select
End With
GetWindowsVersion = ver
End Function
lisen101 2003-10-19
  • 打赏
  • 举报
回复
To goodname008(卢培培,LPP Software):

你好! 我现在还不知道怎么区分98和2000,但是看看我的这种的方法:
if right(lpBuffer,5)='WINNT' '是2000
'这时的桌面的路径为 C:\Documents and Settings\取得的用户名\桌面
else '是98
98我不太清楚路径怎么指定!还望指点!
goodname008 2003-10-18
  • 打赏
  • 举报
回复
GetUserName

VB声明
Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
说明
取得当前用户的名字
返回值
Long,TRUE(非零)表示成功,否则返回零。会设置GetLastError
参数表
参数 类型及说明
lpBuffer String,一个字串缓冲区,预先初始化成由nSize指定的长度。它将用于容纳用户名
nSize Long,初始化成lpBuffer的长度。返回以后,它会包含载入lpBuffer的字符数量
示例
Dim s$, cnt&, dl&
cnt& = 199
s$ = String$(200,0)
dl& = GetUserName(s$, cnt)
Debug.Print Left$(s$, cnt); cnt





GetWindowsDirectory

VB声明
Declare Function GetWindowsDirectory Lib "kernel32" Alias "GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
说明
这个函数能获取Windows目录的完整路径名。在这个目录里,保存了大多数windows应用程序文件及初始化文件
返回值
Long,复制到lpBuffer的一个字串的长度。如lpBuffer不够大,不能容下整个字串,就会返回lpBuffer要求的长度。零表示失败。会设置GetLastError
参数表
参数 类型及说明
lpBuffer String,指定一个字串缓冲区,用于装载Windows目录名。除非是根目录,否则目录中不会有一个中止用的“\”字符
nSize Long,lpBuffer字串的最大长度

goodname008 2003-10-18
  • 打赏
  • 举报
回复
可以先用 GetWindowsDirectory 获得系统被安装在哪个盘,然后用 GetUserName 获得用户名,再针对不同的操作系统就可以找到桌面路径了。
AresChen 2003-10-18
  • 打赏
  • 举报
回复
查API,其中有一个函数是获得系统路径的函数,MSDN上有,我记不清了。
lisen101 2003-10-18
  • 打赏
  • 举报
回复
FileCopy 需要指出 目的地的文件夹

我现在不知道如何得到 用户桌面的位置!
kmzs 2003-10-18
  • 打赏
  • 举报
回复
FillCopy
up
lisen101 2003-10-18
  • 打赏
  • 举报
回复
请高手指点!

7,763

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧