Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Api call from Com

Posted on 2002-03-28
10
Medium Priority
?
275 Views
Last Modified: 2010-05-18
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
Comment
Question by:krishnaveni_a
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
  • 2
  • +1
10 Comments
 
LVL 1

Expert Comment

by:mariab_
ID: 6902181
Which exactly API function do you use?
0
 
LVL 70

Accepted Solution

by:
Éric Moreau earned 200 total points
ID: 6902197
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
 

Author Comment

by:krishnaveni_a
ID: 6904380
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.

 
LVL 1

Expert Comment

by:mariab_
ID: 6904630
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
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 6904937
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
 

Author Comment

by:krishnaveni_a
ID: 6906415
is there any other way rather than passing the fullpath
from the COM to API.?
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 6906828
run the DLL from the same folder as your application is another method (but I prefer passing the full path).
0
 
LVL 1

Expert Comment

by:Moondancer
ID: 6978588
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
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 6979082
points to me!
0
 
LVL 1

Expert Comment

by:Moondancer
ID: 6979285
Finalized!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Suggested Courses

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question