Hi!
This program for Win2k must share resource but it don't want... Why?

Thanks to everybody who can help me.
Mike

;*****************************

.386
.model flat, stdcall
option casemap:none

include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
include \masm32\include\user32.inc
include \masm32\include\masm32.inc
include \masm32\include\netapi32.inc

includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\user32.lib
includelib \masm32\lib\masm32.lib
includelib \masm32\lib\netapi32.lib

.data
MsgCaption db "Error code",0
MsgCaption4 db "Success",0
Msg1 db "Net resource not found", 0
Msg3 db "Resource become shared", 0
Msg4 db "Duplicated net name", 0
retCode db 16 dup (?)
netData SHARE_INFO_502 <>
netName db '1',0,'1',0,'1',0,0 ; "111", 0
netPath db 'D',0,':',0,'\',0,'1',0,'1',0,'1',0,0,0 ; "D:\111", 0
netHost db '\',0,'\',0,'M',0,'I',0,'S',0,'H',0,'A',0,0,0 ; "\Misha", 0

.code
start:
invoke lstrcpy, addr netData.shi502_netname, addr netName
mov netData.shi502_type, STYPE_DISKTREE
mov netData.shi502_permissions, ACCESS_ALL
mov eax, offset netPath
mov netData.shi502_path, eax

mov eax, SIZEOF netData
invoke NetShareAdd,
addr netHost, ; 0 = Local host
502, ; Using SHARE_INFO_502
addr netData, ; pointer
eax ; length

.if eax != 0 ; On error
.if eax==2392
invoke MessageBox, NULL,addr Msg1, addr MsgCaption, MB_OK
.elseif eax==2118
invoke MessageBox, NULL,addr Msg4, addr MsgCaption, MB_OK
.else
invoke dwtoa, eax, addr retCode
invoke MessageBox, NULL,addr retCode, addr MsgCaption, MB_OK
.endif

.else ; Success!
invoke MessageBox, NULL,addr Msg3, addr MsgCaption4, MB_OK
.endif

invoke ExitProcess,NULL
end start

;******************
Posted on 2002-12-17 05:22:22 by Mike
Thanks to everybody... who help me...

There was some errors. This version works properly.

;**********************************************************
.386
.model flat, stdcall
option casemap:none

include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
include \masm32\include\user32.inc
include \masm32\include\masm32.inc
include \masm32\include\netapi32.inc
include \masm32\include\add\macros.inc

includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\user32.lib
includelib \masm32\lib\masm32.lib
includelib \masm32\lib\netapi32.lib

lstrcpyW PROTO :DWORD,:DWORD

.data
MsgCaption db "NetShareAdd",0
netName db '1',0,'1',0,'1',0,0,0 ; "111", 0
netPath db 'D',0,':',0,'\',0,'1',0,'1',0,'1',0,0,0 ; "D:\111", 0

.data?
netData SHARE_INFO_2 <>
digBuf db 16 dup (?)
res dd ?


.code
start:
mov netData.shi2_type, STYPE_DISKTREE
mov netData.shi2_permissions, 0
mov netData.shi2_max_uses, 4
mov netData.shi2_current_uses, 0
mov netData.shi2_passwd, 0 ; no password
m2m netData.shi2_path, offset netPath
mov netData.shi2_netname, offset netName

invoke NetShareAdd,
0, ; 0 = Local host or addr netHost
2, ; Using SHARE_INFO_2
addr netData, ; pointer
offset res ; error

.if eax == 0 ; Success!
invoke MessageBox, NULL,CStr("Share created"), addr MsgCaption, MB_OK
.else ; On error
.if eax==ERROR_ACCESS_DENIED
invoke MessageBox, NULL,CStr("Access denied"), addr MsgCaption, MB_OK
.elseif eax==ERROR_INVALID_LEVEL
invoke MessageBox, NULL,CStr("Invalid level"), addr MsgCaption, MB_OK
.elseif eax==ERROR_INVALID_NAME
invoke MessageBox, NULL,CStr("Invalid name"), addr MsgCaption, MB_OK
.elseif eax==ERROR_INVALID_PARAMETER
invoke MessageBox, NULL,CStr("Invalid parameter"), addr MsgCaption, MB_OK
.elseif eax==NERR_DuplicateShare
invoke MessageBox, NULL,CStr("Duplicate Share"), addr MsgCaption, MB_OK
.elseif eax==NERR_RedirectedPath
invoke MessageBox, NULL,CStr("Redirected Path"), addr MsgCaption, MB_OK
.elseif eax==NERR_UnknownDevDir
invoke MessageBox, NULL,CStr("Unknown Device or Directory"), addr MsgCaption, MB_OK
.else
invoke dwtoa, eax, addr digBuf
invoke MessageBox, NULL,addr digBuf, addr MsgCaption, MB_OK
.endif
.endif

invoke ExitProcess,NULL
end start
;**********************************************************
Posted on 2002-12-18 04:33:15 by Mike