Thread View: borland.public.cppbuilder.nativeapi
7 messages
7 total messages
Started by nivekski
Thu, 22 Jun 2006 23:04
Create a shared network folder?
Author: nivekski
Date: Thu, 22 Jun 2006 23:04
Date: Thu, 22 Jun 2006 23:04
9 lines
973 bytes
973 bytes
Hi Using C++Builder 6 I want to share an existing folder to it is read/write on the local network.Can this be done? Thanks -- Nevikski www.kevsbox.com
Re: Create a shared network folder?
Author: Remy Lebeau (TeamB)
Date: Fri, 23 Jun 2006 10:20
Date: Fri, 23 Jun 2006 10:20
11 lines
1248 bytes
1248 bytes
"nivekski" <nevikski@tisconi.com> wrote in message news:449b2212$1@newsgroups.borland.com... > Using C++Builder 6 I want to share an existing folder to it > is read/write on the local network.Can this be done? Did you look at the WNetAddConnection...() functions yet? Gambit
Re: Create a shared network folder?
Author: nivekski
Date: Fri, 23 Jun 2006 11:07
Date: Fri, 23 Jun 2006 11:07
26 lines
1590 bytes
1590 bytes
Yes I have thanks. And yep that seems like just the thing. However being new to BuilderC++, spent many years in VB and Delphi, I am a bit of a newcomer to this language, so how do you run a api function in C++ please. Thanks -- Nevikski www.kevsbox.com "Remy Lebeau (TeamB)" <no.spam@no.spam.com> wrote in message news:449bc1af$5@newsgroups.borland.com... > > "nivekski" <nevikski@tisconi.com> wrote in message > news:449b2212$1@newsgroups.borland.com... > >> Using C++Builder 6 I want to share an existing folder to it >> is read/write on the local network.Can this be done? > > Did you look at the WNetAddConnection...() functions yet? > > > Gambit > >
Re: Create a shared network folder?
Author: nivekski
Date: Fri, 23 Jun 2006 14:06
Date: Fri, 23 Jun 2006 14:06
72 lines
3073 bytes
3073 bytes
The code below returns the following errors
[C++ Error] mtt.cpp(44): E2034 Cannot convert 'char *' to 'wchar_t'
[C++ Error] mtt.cpp(44): E2141 Declaration syntax error
[C++ Error] mtt.cpp(46): E2034 Cannot convert 'wchar_t' to 'wchar_t *'
[C++ Error] mtt.cpp(50): E2034 Cannot convert 'char *' to 'wchar_t *'
[C++ Error] mtt.cpp(51): E2034 Cannot convert 'char *' to 'wchar_t *'
[C++ Error] mtt.cpp(63): E2034 Cannot convert 'int' to 'wchar_t *'
[C++ Error] mtt.cpp(63): E2342 Type mismatch in parameter 'servername'
(wanted 'wchar_t *', got 'wchar_t')
Any thoughts please folks?
void __fastcall TmainForm::create_share(void)
{
NET_API_STATUS res;
SHARE_INFO_2 p;
DWORD parm_err = 0;
wchar_t shareName = "DTTServer"
p.shi2_netname = TEXT(shareName);
p.shi2_type = STYPE_DISKTREE; // disk drive
p.shi2_remark = TEXT(shareName);
p.shi2_permissions = ACCESS_ALL;
p.shi2_max_uses = -1;
p.shi2_current_uses = 0;
p.shi2_path = TEXT("C:\\DTTServer\\");
p.shi2_passwd = NULL; // no password
res=NetShareAdd(shareName, 2, (LPBYTE) &p, &parm_err);
if(res==0) re1->Text = "Share created.\n";
else re1->Text = "Error: %u\tparmerr=%u\n", res, parm_err;
}
Thanks
--
Nevikski
www.kevsbox.com
"nivekski" <nevikski@tisconi.com> wrote in message
news:449bcb65$1@newsgroups.borland.com...
> Yes I have thanks. And yep that seems like just the thing.
> However being new to BuilderC++, spent many years in VB and Delphi, I am a
> bit of a newcomer to this language, so how do you run a api function in
> C++ please.
>
> Thanks
>
>
> --
> Nevikski
> www.kevsbox.com
> "Remy Lebeau (TeamB)" <no.spam@no.spam.com> wrote in message
> news:449bc1af$5@newsgroups.borland.com...
>>
>> "nivekski" <nevikski@tisconi.com> wrote in message
>> news:449b2212$1@newsgroups.borland.com...
>>
>>> Using C++Builder 6 I want to share an existing folder to it
>>> is read/write on the local network.Can this be done?
>>
>> Did you look at the WNetAddConnection...() functions yet?
>>
>>
>> Gambit
>>
>>
>
>
Re: Create a shared network folder?
Author: Ed Mulroy
Date: Fri, 23 Jun 2006 14:45
Date: Fri, 23 Jun 2006 14:45
53 lines
2756 bytes
2756 bytes
The arguments in the function prototype I found are:
NetShareAdd (
const char *,
short ,
const char * ,
unsigned short);
but the code you show calls it as if it were:
NetShareAdd (
wchar_t,
short,
const unsigned char *,
unsigned long);
. Ed
> nivekski wrote in message
> news:449bf567@newsgroups.borland.com...
>
> The code below returns the following errors
> [C++ Error] mtt.cpp(44): E2034 Cannot convert 'char *' to 'wchar_t'
> [C++ Error] mtt.cpp(44): E2141 Declaration syntax error
> [C++ Error] mtt.cpp(46): E2034 Cannot convert 'wchar_t' to 'wchar_t *'
> [C++ Error] mtt.cpp(50): E2034 Cannot convert 'char *' to 'wchar_t *'
> [C++ Error] mtt.cpp(51): E2034 Cannot convert 'char *' to 'wchar_t *'
> [C++ Error] mtt.cpp(63): E2034 Cannot convert 'int' to 'wchar_t *'
> [C++ Error] mtt.cpp(63): E2342 Type mismatch in parameter 'servername'
> (wanted 'wchar_t *', got 'wchar_t')
>
> Any thoughts please folks?
>
> void __fastcall TmainForm::create_share(void)
> {
>
> NET_API_STATUS res;
> SHARE_INFO_2 p;
> DWORD parm_err = 0;
> wchar_t shareName = "DTTServer"
>
> p.shi2_netname = TEXT(shareName);
> p.shi2_type = STYPE_DISKTREE; // disk drive
> p.shi2_remark = TEXT(shareName);
> p.shi2_permissions = ACCESS_ALL;
> p.shi2_max_uses = -1;
> p.shi2_current_uses = 0;
> p.shi2_path = TEXT("C:\\DTTServer\\");
> p.shi2_passwd = NULL; // no password
>
> res=NetShareAdd(shareName, 2, (LPBYTE) &p, &parm_err);
> if(res==0) re1->Text = "Share created.\n";
> else re1->Text = "Error: %u\tparmerr=%u\n", res, parm_err;
Re: Create a shared network folder?
Author: Remy Lebeau (TeamB)
Date: Fri, 23 Jun 2006 17:16
Date: Fri, 23 Jun 2006 17:16
24 lines
1651 bytes
1651 bytes
"nivekski" <nevikski@tisconi.com> wrote in message
news:449bf567@newsgroups.borland.com...
> wchar_t shareName = "DTTServer"
You are trying to assign a char* string to a single wchar_t character. That
will never work. You need to declare it as a char* instead, ie:
char *shareName = "DTTServer"
Or, because you are using the TEXT macro for the rest of the code, as this
instead:
LPTSTR shareName = TEXT("DTTServer")
If you use this second one, then get rid of the TEXT macro in the other
places that you are using that string:
p.shi2_netname = shareName;
p.shi2_remark = shareName;
Gambit
Re: Create a shared network folder?
Author: nivekski
Date: Fri, 23 Jun 2006 21:02
Date: Fri, 23 Jun 2006 21:02
34 lines
1894 bytes
1894 bytes
Thanks Remy
--
Nevikski
www.kevsbox.com
"Remy Lebeau (TeamB)" <no.spam@no.spam.com> wrote in message
news:449c2274$1@newsgroups.borland.com...
>
> "nivekski" <nevikski@tisconi.com> wrote in message
> news:449bf567@newsgroups.borland.com...
>
>> wchar_t shareName = "DTTServer"
>
> You are trying to assign a char* string to a single wchar_t character.
> That
> will never work. You need to declare it as a char* instead, ie:
>
> char *shareName = "DTTServer"
>
> Or, because you are using the TEXT macro for the rest of the code, as this
> instead:
>
> LPTSTR shareName = TEXT("DTTServer")
>
> If you use this second one, then get rid of the TEXT macro in the other
> places that you are using that string:
>
> p.shi2_netname = shareName;
> p.shi2_remark = shareName;
>
>
> Gambit
>
>
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads