# Reading a string using win32 GetPrivateProfileString

Praveen Attaluri (pattalur@us.oracle.com)
Mon, 30 Aug 1999 18:54:16 -0700

- Messages sorted by: [ date ][ thread ][ subject ][ author ]
- Next message: Nittle Gupta: "Extending Applet Security - Java 1.2.2"
- Previous message: Nell Rehn: "continuation of handshake problem"

    Date: Mon, 30 Aug 1999 18:54:16 -0700

    From: Praveen Attaluri <pattalur@us.oracle.com>

    To: java-security@java.sun.com

    Subject: Reading a string using win32 GetPrivateProfileString

Hi,

I am trying to make a signed applet load a DLL and read an INI file
using the DLL in the netscape browser. All the files in question are on
the local drive.

I have a C DLL called JAVAREADFILE.DLL which calls another DLL.

I have READFILE.JAVA(Wrapper class) with native methods that correspond
to the methods in the JAVAREADFILE.DLL.

The READFILE class contains static native methods and static class
methods. This class is responsible for loading the DLL and calling the
native methods. The class is as follows

public class ReadFile {
static
{
try
{
PrivilegeManager.enablePrivilege("UniversalLinkAccess");
System.loadLibrary("javasnapi");
}
catch( Exception e)
{
}
}

public static String getINIString(String filename, String parameter)
{
PrivilegeManager.enablePrivilege("UniversalLinkAccess");
PrivilegeManager.enablePrivilege("UniversalFileAccess");
String result = getPrivateProfileString(String
filename, String parameter);
return result;
}

public static native String getPrivateProfileString(String filename,
String parameter);
}

The native implementation of getPrivateProfileString() is in
JavaReadFile.DLL. That method in turn calls the windows API
GetPrivateProfileString() with all the needed parameters.

String test = ReadFile.getINIString("C:\ofa.ini", "HostName");

In short, I am just trying to load a DLL and call a windows 32 API
method to read string from a local file using the netscape browser. The
reason for my elaboration was for better understanding of the approach.

Though I provide the entire path of the filename and have the dll in the
program files\communicator\program\java\bin directory , the browser
gives me the error in the getINIString() method. The error is as
follows
java.lang.UnsatisfiedLinkError: getPrivateProfileString()

sometimes it also displays
PrivilegeManager.enableScopePrivilegeHelper()

Any help to resolve this issue is very much appreciated. I had many
other reasons why I had use the above mentioned approach. Any
suggestions about alternate approaches are also very much appreciated

Thanks
Praveen
E-mail: pattalur@us.oracle.com

- Next message: Nittle Gupta: "Extending Applet Security - Java 1.2.2"
- Previous message: Nell Rehn: "continuation of handshake problem"