Archive: System Call WNetAddConnection2


System Call WNetAddConnection2
Hi,
i need to call the function WNetAddConnection2 in my installation program.
this is my code:

!define RESOURCETYPE_DISK 0x00000001
!define RESOURCEDISPLAYTYPE_SHARE 0x00000003
!define CONNECT_UPDATE_PROFILE 0x00000001

StrCpy $R5 "\\\\PARIS-2000--JB\\Temp1"
StrCpy $R6 "Z:"
System::Call "*(i, i, i, i, t, t, t, t)i.s" ;struct NETRESOURCE
Pop $8
System::Call "*$8(n, i ${RESOURCETYPE_DISK}, i ${RESOURCEDISPLAYTYPE_SHARE}, n, t R6, t R5, n, n)"
System::Call "kernel32::WNetAddConnection2(i r8, n, n,i ${CONNECT_UPDATE_PROFILE}) i .r9"
MessageBox MB_OK "ris = [$9]"

When execute The MessageBox print "ris = [error]".
What's wrong?
Thanks in advance.
Paolo


This is the correct "c" code:
NETRESOURCE nr;
memset (&nr, 0x00, sizeof(NETRESOURCE));
nr.dwType=RESOURCETYPE_DISK;
strcpy(nr.lpLocalName,"Z:");
strcpy(nr.lpRemoteName,"\\\\PARIS-2000--JB\\Temp1");
nr.dwDisplayType = RESOURCEDISPLAYTYPE_SHARE;
res=WNetAddConnection2(&nr,NULL,NULL,CONNECT_UPDATE_PROFILE);


Hi all,
I changed the library "kernel32" with "mpr.dll"
System::Call "kernel32::WNetAddConnection2(i r8, n, n,i ${CONNECT_UPDATE_PROFILE}) i .r9"
and now the the MessageBox print "ris = [487]".
I don't know if the struct NETRESOURCE is allocated, filled
correctly.

many thanks
Paolo


Someone can help me?
I need to know if the struct is used correctly.

Thanks in advance


Use single slash in path
$5=r5 in System plugin, $R6=r16
Extract data from struct to check content


!define NR "(i,i,i,i,t,t,t,t) .i"

StrCpy $5 "\\p401\arch"
StrCpy $6 "x:"
System::Call "*${NR}(0,${RESOURCETYPE_DISK},${RESOURCEDISPLAYTYPE_SHARE},0,r6,r5,n,n) .r8"
System::Call "*$8${NR}(.r0,.r1,.r2,.r3,.r4,.r7)"
MessageBox MB_OK "$0, $1, $2, $3, $4, $7"
System::Call 'mpr::WNetAddConnection2(i r8, t n, t n, i ${CONNECT_UPDATE_PROFILE}) i .r9'
MessageBox MB_OK "ris = [$9]"
System::Free $8

Works on my comp ;)

Thank you very much !!
Works very well.