[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.interop

few problems while calling NetShareAdd from C#?

giddy

6/11/2007 9:42:00 AM

hi,

This is the first time i'm calling win32 functions from C#(i did call
MessageBox! though =P) and i think i've done my homework with the
memory management , the call however does not succeed , it fails with
an error.

It fails with error code : 127 (which i cant find in LMErr.h)

I probably doing something wrong with mem allocs. Heres the code:

http://gidsfiles.googlepages.com/network_snip...

Gideon

6 Answers

SvenC

6/11/2007 10:05:00 AM

0

Hi giddy,

> hi,
>
> This is the first time i'm calling win32 functions from C#(i did call
> MessageBox! though =P) and i think i've done my homework with the
> memory management , the call however does not succeed , it fails with
> an error.
>
> It fails with error code : 127 (which i cant find in LMErr.h)
>
> I probably doing something wrong with mem allocs. Heres the code:
>
> http://gidsfiles.googlepages.com/network_snip...

Checkout www.pinvoke.net

http://www.pinvoke.net/default.aspx/netapi32.N...

--
SvenC

giddy

6/12/2007 7:28:00 PM

0

hi ,

thanks , that really helped!

But somehow , i sucessfully make a share. But i cant open it on the
network. Says i dont have privileges. I set to privleges to ALL.

I am using using level 2 with SHARE_INFO_2. Should i use 502?(i'm on
WinXP)

Gideon

SvenC

6/12/2007 8:24:00 PM

0

Hi,

> But somehow , i sucessfully make a share. But i cant open it on the
> network. Says i dont have privileges. I set to privleges to ALL.

Please show the exact source you use and the error code.

> I am using using level 2 with SHARE_INFO_2. Should i use 502?(i'm on
> WinXP)

I don't think so.

What OS is the server which hosts the share? Do you really have full access?
Can you connect manually with explorer or net use?

--
SvenC

giddy

6/13/2007 5:15:00 PM

0

hi ,

sorry , heres a full test project. Shares C:\ on your computer.

>What OS is the server which hosts the share? Do you really have full access?
>Can you connect manually with explorer or net use?

I coded the NetworkShare class only to work on local computers (i set
the servername to NULL). so theres not host.

I have two computers
//GRPGIDEON //workgroup
//GIDEONMAIN //desktop pc
//GIDLAPTOP //laptop pc.

The desktop has an internet connection which it shares with the laptop
via a seperate LAN card. I the E:\ drive on both computers shared ,
with the 'allow my files to be changed' checkbox checked , and i can
access them completely.

However , this might sound un familiar too you?
HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Lsa\forceguest : is
set to 1 on both pcs. If i set it to 0 then i get another set of
options in the sharing and security properties dialog.

Heres what i mean , these are what the property page looks like if i
change forceguest:
http://gidsfiles.googlepages.com/forceg...
http://gidsfiles.googlepages.com/forceg...

All except one share info has properties similar to foreguest 1;

Any idea?

Thanks so much

Gideon


Ben Voigt [C++ MVP]

6/14/2007 4:47:00 AM

0


"giddy" <gidisrael@gmail.com> wrote in message
news:1181754890.160013.60080@n15g2000prd.googlegroups.com...
> hi ,
>
> sorry , heres a full test project. Shares C:\ on your computer.
>
>>What OS is the server which hosts the share? Do you really have full
>>access?
>>Can you connect manually with explorer or net use?
>
> I coded the NetworkShare class only to work on local computers (i set
> the servername to NULL). so theres not host.
>
> I have two computers
> //GRPGIDEON //workgroup
> //GIDEONMAIN //desktop pc
> //GIDLAPTOP //laptop pc.
>
> The desktop has an internet connection which it shares with the laptop
> via a seperate LAN card. I the E:\ drive on both computers shared ,
> with the 'allow my files to be changed' checkbox checked , and i can
> access them completely.
>
> However , this might sound un familiar too you?
> HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Lsa\forceguest : is
> set to 1 on both pcs. If i set it to 0 then i get another set of
> options in the sharing and security properties dialog.

Is that the registry entry for "Simple File Sharing"? NetShareAdd isn't
going to work very well with simple sharing enabled.

>
> Heres what i mean , these are what the property page looks like if i
> change forceguest:
> http://gidsfiles.googlepages.com/forceg...
> http://gidsfiles.googlepages.com/forceg...
>
> All except one share info has properties similar to foreguest 1;
>
> Any idea?
>
> Thanks so much
>
> Gideon
>
>

giddy

6/14/2007 6:41:00 AM

0


> Is that the registry entry for "Simple File Sharing"? NetShareAdd isn't
> going to work very well with simple sharing enabled.

hmm , that makes sense 'Simple File Sharing' , if its 1 , everything
turns "simple". But every example i've seen does'nt talk about this ,
they just assume one has simple file sharing off! And by default , its
turned on!?

What do you propose i do? Turn simple file sharing off on the users
computer , then add/edit shares?? , i probably should alert the user
that i'm changing it?

Thanks

Gideon