• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 280
  • Last Modified:

Api call from Com

I want to refer an .ini file through an API. The API is called from the COM object. When the COM calls the API, the API should refer this ini file.
     In windows 2000 server environment, when i access this API through the dll, the API refers the ini file only if it available in winnt/system32 directory. It is not referring the ini file eventhough it is present in the directory where the APIs are.
     But i need to tell the COM to access the ini file from the directory where the APIs are and not the ini file from the winnt/system32 directory. Please give solution.
0
krishnaveni_a
Asked:
krishnaveni_a
  • 4
  • 2
  • 2
  • +1
1 Solution
 
mariab_Commented:
Which exactly API function do you use?
0
 
Éric MoreauSenior .Net ConsultantCommented:
use this API to read from any INI file:

Private Declare Function GetPrivateProfileString Lib "kernel32" _
                         Alias "GetPrivateProfileStringA" _
                         (ByVal lpApplicationName As String, _
                          ByVal lpKeyName As Any, _
                          ByVal lpDefault As String, _
                          ByVal lpReturnedString As String, _
                          ByVal nSize As Long, _
                          ByVal lpFileName As String _
                         ) As Long
0
 
krishnaveni_aAuthor Commented:
Actually we are having the API which was created by somebody.
But we are having the sample API application. In this, we are using the "GetPrivateProfileString" function  to read ini file as you mentioned above. Here we are passing the value of the argument namely "Filename" as app.path & "/Readme.ini". And API is in separate location not in system directory. But we are having the ini file in both directories such as Direcotry where the API resides and System directory.

We are calling the function which is in API from our own COM. Now it reads the Readme.ini which is in only System directory not in the directory where our API resides.

We are doubted that is there any diffence while calling the API function from COM and calling from the normal application?.



0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
mariab_Commented:
there is no difference between calling the API from COM or else where.

to access file other than the windows directory, you have to specify it with the full path name.

Quote:

"lpFileName
[in] Pointer to a null-terminated string that specifies the name of the initialization file. If this parameter does not contain a full path to the file, the system searches for the file in the Windows directory. "
0
 
Éric MoreauSenior .Net ConsultantCommented:
this is because the App.Path from the COM object is different from App.Path value of the EXE. Can you pass the full path from your EXE to your COM?
0
 
krishnaveni_aAuthor Commented:
is there any other way rather than passing the fullpath
from the COM to API.?
0
 
Éric MoreauSenior .Net ConsultantCommented:
run the DLL from the same folder as your application is another method (but I prefer passing the full path).
0
 
MoondancerCommented:
ADMINISTRATION WILL BE CONTACTING YOU SHORTLY.  Moderators Computer101 or Netminder will return to finalize these if they are still open in 14 days.  Experts, please post closing recommendations before that time.

Below are your open questions as of today.  Questions which have been inactive for 21 days or longer are considered to be abandoned and for those, your options are:
1. Accept a Comment As Answer (use the button next to the Expert's name).
2. Close the question if the information was not useful to you, but may help others. You must tell the participants why you wish to do this, and allow for Expert response.  This choice will include a refund to you, and will move this question to our PAQ (Previously Asked Question) database.  If you found information outside this question thread, please add it.
3. Ask Community Support to help split points between participating experts, or just comment here with details and we'll respond with the process.
4. Delete the question (if it has no potential value for others).
   --> Post comments for expert of your intention to delete and why
   --> YOU CANNOT DELETE A QUESTION with comments; special handling by a Moderator is required.

For special handling needs, please post a zero point question in the link below and include the URL (question QID/link) that it regards with details.
http://www.experts-exchange.com/jsp/qList.jsp?ta=commspt
 
Please click this link for Help Desk, Guidelines/Member Agreement and the Question/Answer process.  http://www.experts-exchange.com/jsp/cmtyHelpDesk.jsp

Click you Member Profile to view your question history and please keep them updated. If you are a KnowledgePro user, use the Power Search option to find them.  

Questions which are LOCKED with a Proposed Answer but do not help you, should be rejected with comments added.  When you grade the question less than an A, please comment as to why.  This helps all involved, as well as others who may access this item in the future.  PLEASE DO NOT AWARD POINTS TO ME.

To view your open questions, please click the following link(s) and keep them all current with updates.
http://www.experts-exchange.com/questions/Q.20266742.html
http://www.experts-exchange.com/questions/Q.20282416.html
http://www.experts-exchange.com/questions/Q.20282828.html
http://www.experts-exchange.com/questions/Q.20282413.html
http://www.experts-exchange.com/questions/Q.20292179.html



*****  E X P E R T S    P L E A S E  ******  Leave your closing recommendations.
If you are interested in the cleanup effort, please click this link
http://www.experts-exchange.com/jsp/qManageQuestion.jsp?ta=commspt&qid=20274643 
POINTS FOR EXPERTS awaiting comments are listed in the link below
http://www.experts-exchange.com/commspt/Q.20277028.html
 
Moderators will finalize this question if in @14 days Asker has not responded.  This will be moved to the PAQ (Previously Asked Questions) at zero points, deleted or awarded.
 
Thanks everyone.
Moondancer
Moderator @ Experts Exchange
0
 
Éric MoreauSenior .Net ConsultantCommented:
points to me!
0
 
MoondancerCommented:
Finalized!
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now