How to know whether a dll is in use

R

root

Friends

How can I tell whether a dll is in use even when it is used in another
user account? (please don't suggest redirecting to a Windows forum)

/root
 
S

Seebs

Friends

How can I tell whether a dll is in use even when it is used in another
user account? (please don't suggest redirecting to a Windows forum)

Well, uhm.

Since there's no such thing as a "dll" on any of the platforms on which I
use C, and the ways in which you'd tell whether a shared library is in use
are completely system specific, it really seems like your question comes down
to:

How do I do something incredibly system specific? Please don't
suggest redirecting to a news group where anyone knows or cares.

Okay. I won't suggest that. I'll merely tell you that there's no useful
answer possible within this context.

-s
 
P

Phil Carmody

root said:
Friends

How can I tell whether a dll is in use even when it is used in another
user account? (please don't suggest redirecting to a Windows forum)

3/10.

1/10 for content, 1/10 for effort, and 1/10 just out of sympathy
for your poor abject stupidity.

Phil
 
J

jacob navia

root a écrit :
Friends

How can I tell whether a dll is in use even when it is used in another
user account? (please don't suggest redirecting to a Windows forum)

/root


--
Learn more or lose your rights!
http://www.guncontrolkills.com/
http://www.gunbanobama.com/ <<<<<-------
Learn more or lose your rights!

I would have answered that question, but I read your .sig, and
well...

I wouldn't say that you are an ass because (as anyone can
find out) asses are useful. The *do* essential work.

I have great respect for the president of the U.S.
 
A

Antoninus Twink

How can I tell whether a dll is in use even when it is used in another
user account? (please don't suggest redirecting to a Windows forum)

I am not a Windows expert, but I believe I know enough to answer your
question.

Windows has an extraordinary system of file locking, so that if one
process has a file open, even if it's just for reading, then it gets
locked so that no other process can open it, even if it's just for
reading. This seems screwy to me, but judging by the amount of software
available for Windows, I guess it works out somehow. I think this is why
you need to reboot a Windows machine even if all you've done is install
a new version of Free Cell - it's impossible to overwrite an open file.

Anyway, I think all you need to do is something like:

char *path = resolve_full_path("libtwink.dll"); /* use an appropriate
function here! */

FILE *fp = fopen(path, "rb"); /* note need for b on Windows */

if(fp == NULL && errno == EACCES) {
/* DLL is in use by another process */
}
 
A

Antoninus Twink

root a écrit :

I would have answered that question, but I read your .sig, and well...

I don't think it makes much sense not to answer questions just because
you disagree with the poster's opinions. If that were the case, for
example, then I'd never help out Heathfield with his beginner's level C
errors.
I have great respect for the president of the U.S.

So do the majority of Americans - we voted him into office, after all.

Sure, America has its share of wackos, but then so does Europe. I hope
people don't stop talking with you just because the Swiss have banned
mosques. Best just to ignore the lunatic fringe on both sides of the
Atlantic.
 
A

Antoninus Twink

Which shows how real people, despite political correctness, have had
enough of other religions being forced down their throat at gun point. A
lot of the voters questioned privately asked "How many Christian
churches are tolerated in Muslim strongholds". And we all know the
general answer to that one ...

Fair point, but you have to admit that while christian fundamentalists -
the likes of Heathfield and his ilk - might be a bit smug, irritating
and preachy, at least they're not likely to sit next to you on the
subway wearing a belt packed with explosives. There are different
degrees of wackiness...
 
R

root

Antonius

This is bullshit. Americans had no right to vote for Obama because he is
not a native-born US citizen! No birth certificate = no right to be
president. Even so, a LOT less than 50% of Americans cast a vote for
Obama. Many abstained.

The website is correct, Obama's record on gun rights is abysmal.

/root
 
S

Seebs

This is bullshit. Americans had no right to vote for Obama because he is
not a native-born US citizen!

I'm sorry, this is comp.lang.c, not alt.kooks. While a complete diagnosis
of your problem is not topical, my guess is you forgot to put your tinfoil
hat on shiny side out.

-s
 
R

robertwessel2

I am not a Windows expert, but I believe I know enough to answer your
question.

Windows has an extraordinary system of file locking, so that if one
process has a file open, even if it's just for reading, then it gets
locked so that no other process can open it, even if it's just for
reading. This seems screwy to me, but judging by the amount of software
available for Windows, I guess it works out somehow. I think this is why
you need to reboot a Windows machine even if all you've done is install
a new version of Free Cell - it's impossible to overwrite an open file.

Anyway, I think all you need to do is something like:

char *path = resolve_full_path("libtwink.dll"); /* use an appropriate
function here! */

FILE *fp = fopen(path, "rb"); /* note need for b on Windows */

if(fp == NULL && errno == EACCES) {
  /* DLL is in use by another process */


That's both OT and untrue.

A Windows application has control of what sharing is allowed for open
files. By default files opened for read may be opened for read by
other processes, while files opened for write are exclusive (although
the application, at the OS API level, can change the default
behavior). This usually includes executables opened for execution as
well. Windows sometimes opens executables for the duration, and
sometimes not, based on several factors (for example, Windows will
usually copy executables from removable or network devices, and *not*
keep the source file open). But even when it's open, you typically
*can* open it for read and you obviously can open it if Windows hasn't
kept it open). So your code won't actually detect anything.

You can try to open it for write, and that *will* fail if the
executable is open (IOW, it's running and not on a network share or
similar), but that can obviously be problematic if you succeed. Using
the OS functions (or an MS CRT extension like _fsopen() ), you could
open a file read-only but exclusive, and that would detect if anyone
had the file open (again, that doesn't help in the network share
case). But even that carries a (small) risk in that it would leave
the file locked for a time, which might cause and ill timed
application start to fail.

And, of course, security brings its own set of issues.
 
A

Antoninus Twink

On 1 Dec 2009 at 19:44, (e-mail address removed) wrote:
[snip interesting explanation]

Thanks - it's always nice to learn something new.

I was going based on my experience a few years ago when I had to use
Windows to create a PDF. If you had the PDF open in Acroread and tried
to update the PDF, you couldn't actually overwrite it because Acroread
had the file locked. I was told by someone that Windows locks files open
for reading by default, so it's interesting to find out that actually
this insane misfeature was a conscious choice by the cretins who put
together Adobe's piece of crapware.
 
A

Antoninus Twink

While a complete diagnosis of your problem is not topical, my guess is
you forgot to put your tinfoil hat on shiny side out.

Yes, it's just as crazy as the ludicrous twin towers conspiracy
theories...

Let's face it, Obama has even produced his birth certificate to satisfy
these maniacs, and as soon as he does that they find some new spurious
grounds to object to it. It's a pointless exercise trying to convince
them - it's like trying to reason with Heathfield.
 
N

Nick Keighley

Huh? It's clear he means Obama.

and? In order to do a comparison you need something to compare with.
"What do you respect most of Obama and <gronk>?"
 
G

gwowen

Since there's no such thing as a "dll" on any of the platforms on which I
use C

[snip]

A simple "I don't know would suffice" or (better) silence.
You don't have to reply to every thread, you know, especially if you
all you're going to say is "I have nothing constructive to add."
 
S

Seebs

A simple "I don't know would suffice" or (better) silence.

Depends on what I'm trying to communicate.
You don't have to reply to every thread, you know, especially if you
all you're going to say is "I have nothing constructive to add."

Advice on where you might get better answers is constructive. An explanation
of why a C group might not have the best possible answers about Windows might
also be helpful to a newbie.

-s
 
D

Dik T. Winter

Jacob is not Swiss I think.
> The Swiss have not banned Mosques. Only the Minarets which sit on top of
> them. And they haven't done that yet either.
>
> What is interesting is that despite public polls, the private poll was
> totally the other way around to expectations based on interviews.
>
> Which shows how real people, despite political correctness, have had
> enough of other religions being forced down their throat at gun point.

No. There is a huge difference between the two. The interviews were a
cross-section of the population while the poll consisted only of those
who felt strongly about the issue (about 54 % of the population did vote).
 
D

Dik T. Winter

> On 1 Dec 2009 at 19:44, (e-mail address removed) wrote:
> [snip interesting explanation]
>
> Thanks - it's always nice to learn something new.
>
> I was going based on my experience a few years ago when I had to use
> Windows to create a PDF. If you had the PDF open in Acroread and tried
> to update the PDF, you couldn't actually overwrite it because Acroread
> had the file locked.

Right. And this is different from having a file open multiple times for
reading only (which *is* allowed).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top