Thread View: borland.public.cppbuilder.nativeapi
8 messages
8 total messages
Started by Jeff
Wed, 27 Jun 2007 16:44
Directory Contents
Author: Jeff
Date: Wed, 27 Jun 2007 16:44
Date: Wed, 27 Jun 2007 16:44
15 lines
1337 bytes
1337 bytes
Does anyone know a way to obtain a list of files in a directory without
opening any of the files? When I use the code below FindFirst() returns 5
(Access denied) because another application has the files open.
TSearchRec srSearch;
if (FindFirst(strPath, faAnyFile, srSearch) == 0)
{
do
{
strFileInfo += srSearch.Name
} while (FindNext(srSearch) == 0);
FindClose(srSearch);
}
}
Re: Directory Contents
Author: Remy Lebeau (TeamB)
Date: Wed, 27 Jun 2007 16:57
Date: Wed, 27 Jun 2007 16:57
19 lines
1571 bytes
1571 bytes
"Jeff" <Jeff@nospam.com> wrote in message news:46829425@newsgroups.borland.com... > Does anyone know a way to obtain a list of files in a directory > without opening any of the files? You already know how to do that, because you are already doing it. The Find...() functions do not open any of the files at all. > When I use the code below FindFirst() returns 5 (Access denied) > because another application has the files open. That should not be factor. Something else has to be causing the issue. You probably don't have access to the folder itself that you are trying to scan through. Gambit
Re: Directory Contents
Author: Jeff
Date: Wed, 27 Jun 2007 17:33
Date: Wed, 27 Jun 2007 17:33
6 lines
1292 bytes
1292 bytes
> That should not be factor. Something else has to be causing the > issue. You probably don't have access to the folder itself that you > are trying to scan through. Oops, you're right, I think it's because I'm running as a system service. I'll need to impersonate the logged on user. Thanks Gambit!
Re: Directory Contents
Author: Remy Lebeau (TeamB)
Date: Wed, 27 Jun 2007 18:07
Date: Wed, 27 Jun 2007 18:07
12 lines
1308 bytes
1308 bytes
"Jeff" <Jeff@nospam.com> wrote in message news:46829f91$1@newsgroups.borland.com... > Oops, you're right, I think it's because I'm running as > a system service. A service has full access to the local machine, assuming it is running in the SYSTEM account, which it does by default. Gambit
Re: Directory Contents
Author: Jeff
Date: Wed, 27 Jun 2007 18:58
Date: Wed, 27 Jun 2007 18:58
27 lines
2367 bytes
2367 bytes
> Oops, you're right, I think it's because I'm running as a system service. > I'll need to impersonate the logged on user. Thanks Gambit! Gambit please help, I'm trying to use WTSGetActiveConsoleSessionId() in BCB 2006 and it says it's an undefined function. When I add "_WIN32_WINNT=0x0501" to the defines I get compilation errors from Windows.hpp: Errors: [C++ Error] Windows.hpp(2435): E2040 Declaration terminated incorrectly [C++ Error] Windows.hpp(2436): E2040 Declaration terminated incorrectly [C++ Error] Windows.hpp(2437): E2040 Declaration terminated incorrectly [C++ Error] Windows.hpp(2438): E2040 Declaration terminated incorrectly [C++ Error] Windows.hpp(2439): E2040 Declaration terminated incorrectly [C++ Error] Windows.hpp(2440): E2040 Declaration terminated incorrectly [C++ Error] Windows.hpp(2441): E2040 Declaration terminated incorrectly [C++ Error] Windows.hpp(2442): E2040 Declaration terminated incorrectly Code from Windows.hpp errors refer to: static const Shortint WTS_CONSOLE_CONNECT = 0x1; static const Shortint WTS_CONSOLE_DISCONNECT = 0x2; static const Shortint WTS_REMOTE_CONNECT = 0x3; static const Shortint WTS_REMOTE_DISCONNECT = 0x4; static const Shortint WTS_SESSION_LOGON = 0x5; static const Shortint WTS_SESSION_LOGOFF = 0x6; static const Shortint WTS_SESSION_LOCK = 0x7; static const Shortint WTS_SESSION_UNLOCK = 0x8;
Re: Directory Contents
Author: Jeff
Date: Wed, 27 Jun 2007 18:59
Date: Wed, 27 Jun 2007 18:59
4 lines
1196 bytes
1196 bytes
> A service has full access to the local machine, assuming it is running > in the SYSTEM account, which it does by default. I'm accessing a directory on a network server inside a domain.
Re: Directory Contents
Author: Remy Lebeau (TeamB)
Date: Wed, 27 Jun 2007 19:38
Date: Wed, 27 Jun 2007 19:38
14 lines
1527 bytes
1527 bytes
"Jeff" <Jeff@nospam.com> wrote in message news:4682b3b5$1@newsgroups.borland.com... > I'm accessing a directory on a network server inside a domain. By default, a service has no access to the network at all. The service must be run in a user account that has network access, such as the NETWORKSERVICE account, or else you will have to perform your directory scan in a thread that is impersonating a user account that has network access. Gambit
Re: Directory Contents
Author: Remy Lebeau (TeamB)
Date: Fri, 29 Jun 2007 05:35
Date: Fri, 29 Jun 2007 05:35
50 lines
3205 bytes
3205 bytes
"Jeff" <Jeff@nospam.com> wrote in message
news:4682b382$1@newsgroups.borland.com...
> Gambit please help, I'm trying to use WTSGetActiveConsoleSessionId()
> in BCB 2006 and it says it's an undefined function.
Your value for the _WIN32_WINNT precompiler define is too small. The
winbase.h header declares that function only if the value is 0x501 or
higher. The value is intialized to 0x500 by default.
If you don't want to deal with that, then you can always import the
function dynamically via GetProcAddress() at runtime. You will have
to do that anyway if you want your service to run on pre-XP machines.
If you don't do this, then the executable will fail to run at all on
those older systems.
> When I add "_WIN32_WINNT=0x0501" to the defines I get
> compilation errors from Windows.hpp:
That is because those particular constants are already defined by
Microsoft in winuser.h using #define statements. As is often the
case, Microsoft's use of precompiler statements for declarations
interfers with non-Microsoft environments, such as Borland's. Since
precompiler statements are processed before the compiler runs, the
errors are accurate because the following is what the compiler is
actually seeing:
static const Shortint 0x01 = 0x1;
static const Shortint 0x02 = 0x2;
static const Shortint 0x03 = 0x3;
static const Shortint 0x04 = 0x4;
static const Shortint 0x05 = 0x5;
static const Shortint 0x06 = 0x6;
static const Shortint 0x07 = 0x7;
static const Shortint 0x08 = 0x8;
That is clearly erroneous code. You would have to #undef those
constants in order for Windows.hpp to compile properly.
In addition to that, I find it odd that Borland is not using
$EXTERNALSYM statements in Windows.pas for those constants like it
normally does for all other predefined API constants. So this is a
double-edged issue - Microsoft's annoying coding style coupled with a
bug in Borland's code. Had $EXTERNALSYM been used, those declarations
would not appear in Windows.pas at all, and your code would inherit
the constants from winbase.h directly instead, and all would be good.
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