fopen for a network path file

hey ppl,

can u pls help me out on this.i am able to easily open a file with
fopen in a network path but when i use it as a service with the same
fopen function it relly doesnt work.if i write log for the function it
says not able to open the file? can u tell why is that so???? why this
discrepany when i use it as a windows service and not in an
application? pls help me out thanks!!!

0
9/26/2007 12:06:26 PM
vc.mfc 33608 articles. 0 followers. Follow

5 Replies
777 Views

Similar Articles

[PageSpeed] 9

On Sep 26, 5:06 pm, sriram bala <sriramga...@gmail.com> wrote:
> hey ppl,
>
> can u pls help me out on this.i am able to easily open a file with
> fopen in a network path but when i use it as a service with the same
> fopen function it relly doesnt work.if i write log for the function it
> says not able to open the file? can u tell why is that so???? why this
> discrepany when i use it as a windows service and not in an
> application? pls help me out thanks!!!

Here is my code in case if one wants to see it



FILE * pFile;
	pFile = fopen ("\\\\192.168.1.19\\DcmImg\\4687\\8829\\54879.dcm","w
+");
	//"e:\\EchoServiceAdmin\\Debug\\MVU_aboCompress.exe \"\\\
\192.168.1.19\\DcmImg\\4684\\8826\\54876.dcm\" 0 1 1";,"w+");
	if (pFile!=NULL)
	{
		fputs ("fopen example",pFile);
		fclose (pFile);
	}
	else
	{
		SvcDebugOut (_T("not able to open the file"));
		return 0;
	}
}

0
9/26/2007 12:07:16 PM
I'm no service expert, but could it be that your service's log in ID doesn't 
have permission to the same network access as your normal user ID?

Tom

"sriram bala" <sriramganga@gmail.com> wrote in message 
news:1190808386.870378.317960@g4g2000hsf.googlegroups.com...
> hey ppl,
>
> can u pls help me out on this.i am able to easily open a file with
> fopen in a network path but when i use it as a service with the same
> fopen function it relly doesnt work.if i write log for the function it
> says not able to open the file? can u tell why is that so???? why this
> discrepany when i use it as a windows service and not in an
> application? pls help me out thanks!!!
> 

0
tom.nospam (3240)
9/26/2007 3:18:21 PM
You are using a device name like e:.  This does not exist for a service.  Logical device
names are set up when you log in, and a service does not share the same environment as a
logged-in service.  Furthermore, if you log the service in as the LocalService account,
you do not have access to network shares unless you set a special registry key.  You would
have to use UNC names, e.g., \\machinename\sharename\path, but the sharename is not
accessible unless you log the service in with a real account.  Bottom line: services are
not interactive user accounts, and programs don't behave the same.
						joe

On Wed, 26 Sep 2007 05:06:26 -0700, sriram bala <sriramganga@gmail.com> wrote:

>hey ppl,
>
>can u pls help me out on this.i am able to easily open a file with
>fopen in a network path but when i use it as a service with the same
>fopen function it relly doesnt work.if i write log for the function it
>says not able to open the file? can u tell why is that so???? why this
>discrepany when i use it as a windows service and not in an
>application? pls help me out thanks!!!
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15974)
9/26/2007 3:31:17 PM
Joe,

It looked to me like the line using e: was commented out.  But you are 
right.  Mapped drives don't work from services very easily.  I think OP is 
trying to use an IP address rather than a UNC.

Tom

"Joseph M. Newcomer" <newcomer@flounder.com> wrote in message 
news:9iukf39fc69n2dtstcqlehtfq6u9j08ihs@4ax.com...
> You are using a device name like e:.  This does not exist for a service. 
> Logical device
> names are set up when you log in, and a service does not share the same 
> environment as a
> logged-in service.  Furthermore, if you log the service in as the 
> LocalService account,
> you do not have access to network shares unless you set a special registry 
> key.  You would
> have to use UNC names, e.g., \\machinename\sharename\path, but the 
> sharename is not
> accessible unless you log the service in with a real account.  Bottom 
> line: services are
> not interactive user accounts, and programs don't behave the same.
> joe
>
> On Wed, 26 Sep 2007 05:06:26 -0700, sriram bala <sriramganga@gmail.com> 
> wrote:
>
>>hey ppl,
>>
>>can u pls help me out on this.i am able to easily open a file with
>>fopen in a network path but when i use it as a service with the same
>>fopen function it relly doesnt work.if i write log for the function it
>>says not able to open the file? can u tell why is that so???? why this
>>discrepany when i use it as a windows service and not in an
>>application? pls help me out thanks!!!
> Joseph M. Newcomer [MVP]
> email: newcomer@flounder.com
> Web: http://www.flounder.com
> MVP Tips: http://www.flounder.com/mvp_tips.htm 

0
tom.nospam (3240)
9/26/2007 3:46:31 PM
I see, I guess I missed that.  But actually I think the same restriction applies.  There
are some keys under LanManServer that need to be set (talk about a truly retro name!), but
I don't recall all the details.  Nonetheless, I find it is a common mistake that people
think that just because a program runs one way in a logged-in user session that it will
run identically when run under a service logged in with a generic service account, or even
a particular account that is not the same as the logged-in user.
					joe


On Wed, 26 Sep 2007 08:46:31 -0700, "Tom Serface" <tom.nospam@camaswood.com> wrote:

>Joe,
>
>It looked to me like the line using e: was commented out.  But you are 
>right.  Mapped drives don't work from services very easily.  I think OP is 
>trying to use an IP address rather than a UNC.
>
>Tom
>
>"Joseph M. Newcomer" <newcomer@flounder.com> wrote in message 
>news:9iukf39fc69n2dtstcqlehtfq6u9j08ihs@4ax.com...
>> You are using a device name like e:.  This does not exist for a service. 
>> Logical device
>> names are set up when you log in, and a service does not share the same 
>> environment as a
>> logged-in service.  Furthermore, if you log the service in as the 
>> LocalService account,
>> you do not have access to network shares unless you set a special registry 
>> key.  You would
>> have to use UNC names, e.g., \\machinename\sharename\path, but the 
>> sharename is not
>> accessible unless you log the service in with a real account.  Bottom 
>> line: services are
>> not interactive user accounts, and programs don't behave the same.
>> joe
>>
>> On Wed, 26 Sep 2007 05:06:26 -0700, sriram bala <sriramganga@gmail.com> 
>> wrote:
>>
>>>hey ppl,
>>>
>>>can u pls help me out on this.i am able to easily open a file with
>>>fopen in a network path but when i use it as a service with the same
>>>fopen function it relly doesnt work.if i write log for the function it
>>>says not able to open the file? can u tell why is that so???? why this
>>>discrepany when i use it as a windows service and not in an
>>>application? pls help me out thanks!!!
>> Joseph M. Newcomer [MVP]
>> email: newcomer@flounder.com
>> Web: http://www.flounder.com
>> MVP Tips: http://www.flounder.com/mvp_tips.htm 
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15974)
9/27/2007 4:50:08 AM
Reply:

Similar Artilces:

Can't open file
I loaded MS Powerpoint (I was one of the unlucky ones who purchased the XP Office version that did not include it), and two of my files will no longer open in Publisher. They are based on an inventory template. Other existing ..pub files I had created do open, but these two do not. The templates display, then an error message pops up saying "Microsoft has encountered an error and needs to close. We are sorry for the inconvenience". The program then shuts down. The error report contents are long. I have tried uninstalling and reinstalling the program, but to no avail. Any ideas...

Save a new file with the name that is in cell "C7"
Here is what I want to do: Open up a template. Enter information. Click on save, and when the window shows up asking me to name the file, I want it to automatically use a file name with the value in cell C7. As an example, if cell C7 has "Milton 287-12", I want to automatically name the file"Milton 287-12" when I save for the first time. Is this possible? Thanks, Joe Hi, Lunker, Try pasting the following code into a macro sheet and running it with Alt-F8 Change the path to whatever you require between the quote in line 3 and "A1" to whatever cell you want...

Converting JPG files to VSD files?
Three questions; 1. Is there a simple way to convert JPG files to Viso? 2. Or is there a way to scale them to a Viso drawing? 3. If 1-2 can't be done what if I was to draw lines on top of the imported jpg floor plan layout using it as a guide then save that as a vsd file? Thanks Bud jpgs are bit oriented and cannot be converted to visio. you might consider inserting your image into a background page and then create your drawing on an associated foreground page (using page setup). I'd probably use the building plan templates because of the dimensioning stencils to validate tha...

Get special folder path
Hello, I'm developping an app with VC++ 6.0 and MFC, and I need to get the path of Windows special folders (in particular, folder "My Music", wherever the user may have moved it). I was told there is a possibility for apps running under Windows XP to get this information ? Does somebody know how ? Thank for any help -- Ceci est une signature automatique de MesNews. Site : http://www.mesnews.net ByB wrote: > Hello, > > I'm developping an app with VC++ 6.0 and MFC, and I need to get the path > of Windows special folders (in particular, folder "My M...

Need Help setting up .oft file
I need some help setting up an .oft file to apply to a rule for an autoresponse. I use a popmail server so the autoresponse function in Outlook does not apply to my application. Can anyone offer some advice? Thanking you in advance. If we knew your version of Outlook and if you used word as your editor we could help... where you run into problems doing it would help us target the response as well. -- Diane Poremsky [MVP - Outlook] Author, Teach Yourself Outlook 2003 in 24 Hours Need Help with Common Tasks? http://www.outlook-tips.net/beginner/ Outlook 2007: http://www.slipstick.com/ou...

e-mail settings and pst file
I am planning to copy the .pst file from my desktop to my laptop to ensure I can work away from my desk. The laptop accesses the internet using a mobile bradband dongle and uses slightly diferent e-mail settings to the desktop. When I transfer the .pst file will the e-mail settings transfer to the laptop or can I use settings just for the laptop and keep them even when the ..pst transfers across? Account settings are not part of the .PST file, just make sure Outlook is closed on BOTH machines when doing the .PST transfers. Hal -- Hal Hostetler, CPBE -- hhh@kvoa.com Senior Engineer...

Pivot Tables
I have a excel file a fairly large database in one sheet and another sheet for pivot tables from that databse. once the pivot tables are loaded the capacity jumps from a mere 175 or 200 kb to 9 or 10 mb. and gives me difficulties in saving the file in network drives. how can i keep the file to low capacity and also keep the pivot tables information. I refresh the Pivot tables only once a week and the result stays as it is till the next week. -- M Imran Buhary I used to have a similar problem. The answer, as I see it, is to recognise that the sheet with the database in it shoudl be in ...

Word 2010: cannot save normal.dotm file?
Using the Word 2010 beta on Win7. I cannot save my Normal.dotm file - at least not usefully. I can open the file, edit it, add macros to it, whatever, and it will save (in the folder directory, the .dotm file will show a change in file size). But if I close Word, or if I open a new document in Word, the Normal.dotm file is reset to the default, losing any changes I've made. I can save and use other .dotm templates; but not the default Normal.dotm template. You've posted to the Mac Word group, so there isn't much help available here on a Beta version for Windows. Tr...

can you download files from microsoft 2003 to 2007?
Please use the big textbox to post a comprehensible question. "Download" to me means to transfer a file from a site on the Internet to a local computer; and there is no such product as "microsoft 2003". What do you have? What are you trying to accomplish? John W. Vinson [MVP] ...

Things that have gone wrong with my Money file in the past 2 days
1. My two bank accounts that download statements via the MSN Money website (which in turn uses the Yodlee service) stopped updating both on the website and within Money. The error message said to fix it I needed to stop using the "online services" then reenable it, but when I did, I received an "Account setup is unavaiable" message on one of the two accounts. I did this 4 or 5 times, for kicks. Finally today I got them both to work.. for now. 2. The starting balances of two other bank accounts conveniently reset themeslves from one value to another, seemingly randomly, ...

Insert XML string into XML File: Part 2
Thanks to some good help from a previous post, I have been able to create well formed xml as part of a report logger app. However, I still have a small problem. When I add new xml to the log file, the new nodes are appended to the original file. What I really want is for the log file to grow as "report nodes" are added. Also, I am a bit concerned about performance, particularly as the file grows in size. I must write to an xml file (vs. a database) and am trying to understand the best way to do this. I prefer to not use "temp files" and would like to just modify the ...

Viewing and selecting files
I must be missing something. I think I have V11 of media player and it's suposed to be easy to use. I just want to simply view and select mp3's from a folder on my C drive and then burn to a cd as a data cd. I only want to see the files in a certain folder and not all the music files on my computer. This was very straight forward using Easy CD Creator. How is this done? It this possible? Thanks in advance. In WMP, press F3 and in the dialog that appears, add the folder containing the MP3's to the list and click OK. This will add the MP3's to the library. Then...

Why can't I save Publisher files since an XP upgrade?
-- 89Q Radio Trial version? Maybe the time has run out. Are you saving to your hard drive? Can you open files? Do you get an error? What version Publisher? -- Mary Sauer MSFT MVP http://office.microsoft.com/ http://msauer.mvps.org/ news://msnews.microsoft.com http://officebeta.iponet.net/en-us/publisher/FX100649111033.aspx "Coy" <Coy@discussions.microsoft.com> wrote in message news:C4666111-8322-43AA-BD05-A1E24D4D7C23@microsoft.com... > > -- > 89Q Radio Mary: I have used Publisher 2002 for a couple of years now. It was only recently (since an upgrade t...

file save as word 2003 xp pro
Scenario I open a document called test.doc and make a change. I use the file save as option and call the file test.doc. It doesn't prompt me to overwrite the existing test.doc shouldn't it?? I belive it did in earlier versions?? No - if you open a document and use SaveAs to save it with the same name you won't get a prompt. If you use SaveAs to save it with a different existing name, you will. -- <>>< ><<> ><<> <>>< ><<> <>>< <>><<> Graham Mayor - Word MVP My web site...

Event log file is full
I creating an ASP .Net application with a SQL Server database backend. When I try to create as connection using the wizard the following error appears "The event file log is full. How can I clear this file? Where is the file located. Any assistance is appreciated. -- Tony On Dec 16, 12:35=A0am, Tony A. <To...@discussions.microsoft.com> wrote: > I creating an ASP .Net application with a SQL Server database backend. = =A0When > I try to create as connection using the wizard the following error appear= s > "The event file log is full. > > How...

CSV file displaying ###### instead of $nn,nnn
Hi I used PHP's 'fgetcsv' (http://us3.php.net/manual/en/function.fgetcsv.php) to write data to a ..csv file. The data pretty much formatted when I opened it in 'Context' (http://www.context.cx/) but when opened in Excel 2003, one column which contains data like *"$105,138"* is showing as *########*. When the cell is hovered over it shows *$105,138* in the tip but shows *105138* in the top textbox (the one next to fx label) How do I 'tell' Excel to display *$105,138* instead of *########* ? Thanks -- anjanesh Freelance Developer --------------------...

REading Publisher files burned to a CD
Copy the files to your hard drive. Publisher doesn't do well with removable media. -- Mary Sauer MS MVP http://office.microsoft.com/ http://msauer.mvps.org/ news://msnews.microsoft.com "Bruno Ottavi" <bottavi@insight.rr.com> wrote in message news:dekVd.2395$3t3.1039@fe2.columbus.rr.com... > > ...

missing installation files
After installing the MSN premier software with verizon dsl, outlook stopped working. I can't check email, I can't modify my email accounts and doing the detect and repair option from the help menu leads to an error message that says that the patch installation files or the source file is missing. I've tried reinstalling and doing a repair from the CD but I get a similar message saying that the installation files are missing. I also tried to download the latest office updates, but I get an error message saying the same thing: "installation files (.msp) are missing......

Importing CSV file field mapping
When importing a CSV file for contacts or leads: How can I expand the drop down list of field choices under the Microsoft CRM fields to included fields such as Account, alternative address information, etc.? The current limited amount of fields keeps me from importing information currently contained within our Outlook based contact system. What I do to expand the number of fields exported from Outlook is to Export the contact records from Outlook to MS Access, then export the access contact table as a CSV file. This process gives me more information to import (i.e., other addres...

can you edit a print shop file in publisher?
Is the print shop software compatible with MS Publisher. No, it is not compatible. You could export your printshop item as an image and insert that image into Publisher, but you will only be able to edit the image as an image, you won't be able to edit text, etc. -- Brian Kvalheim Microsoft Publisher MVP http://www.publishermvps.com This posting is provided "AS IS" with no warranties, and confers no rights. "Tthomas" <Tthomas@discussions.microsoft.com> wrote in message news:96D872CD-E940-4891-86F9-23F0E21CC8F2@microsoft.com... > Is the print shop softwa...

show log file at the end
Hi, there, I would like to show the log file, which contains the information about the commands exectued and the processed files' name, at the end of program. How to do that? And how to show a txt file in the dialog? Any suggestion and sample code are highly appreciated! Thanks Gary ...

.NET File/Folder Browser that is similar to the windows explorer
Hello, i need a .NET WinForms control that can be used to explore the local file system just the same way Windows Explorer does. I only need the tree view part of it (which usually is the left frame of the windows explorer). That tree view is supposed not only to show folders but files as well. That control also should be able to filter files by a certain pattern (e.g. only display *.txt files). I found http://www.codeproject.com/KB/miscctrl/FileBrowser.aspx but that control has too many bugs and my schedule is too tight to fix it. I would be happy to find a commercial pro...

delete saved files
Is there a way of deleting the previously saved Excel files? It is maddening to see all those things that I can no longer open. -- Dawn Tools > Options > GeneralTab > Uncheck the Recently used files box Vaya con Dios, Chuck, CABGx3 "herd" <herd@discussions.microsoft.com> wrote in message news:089179B0-5516-4934-ACE9-9D664BF5672E@microsoft.com... > Is there a way of deleting the previously saved Excel files? It is maddening > to see all those things that I can no longer open. > -- > Dawn In office 2007 I have headings of Home, Insert, Page Layout, F...

How Can I View a .pub File Without Publisher Installed on my Machine?
I have a .pub file but cannot view it. I do not have publisher installed on my machine. Is there a publisher viewer that I can download to view .pub files? Thanks, Jason Hi Jason (anonymous@discussions.microsoft.com), in the newsgroups you posted: || I have a .pub file but cannot view it. I do not have || publisher installed on my machine. Is there a publisher || viewer that I can download to view .pub files? Visit the following link: http://www.mvps.org/publisher/sharing.html -- Brian Kvalheim Microsoft Publisher MVP http://www.mvps.org/publisher ~pay it foward~ This posting is pr...

rename Exchange 2003 database files?
Exchange 2003 + SP1 on 2-node A/A cluster. We originally created 8 databases, 4 on each node, to balance the number of mailboxes. We named the databases based on the first letters of the users' last names: "AthruC", "DthruG", "HthruK", "LthruN", etc. We have now had to move the "M" and "N" mailboxes to another database to re-balance the number of mailboxes on each server. We'd like to rename the databases to be more generic, but haven't found a way to do it. I can't find anything on the MS Knowledgebase either. Can an...