PrfOpenProfile - WPS reset/hang - OS2

This is a discussion on PrfOpenProfile - WPS reset/hang - OS2 ; Check hini after calling it, and call WinGetLastError if it comes back NULLHANDLE. Also, as stupid as it sounds, use all CAPITAL letters in the INI file name. Not sure about the WPS reset. There is something more evil afoot ...

+ Reply to Thread
Results 1 to 7 of 7

Thread: PrfOpenProfile - WPS reset/hang

  1. Re: PrfOpenProfile - WPS reset/hang

    Check hini after calling it, and call WinGetLastError if it comes back
    NULLHANDLE.

    Also, as stupid as it sounds, use all CAPITAL letters in the INI file name.

    Not sure about the WPS reset. There is something more evil afoot there.

    Andi B. wrote:
    > Anyone experienced with PrfOpenProfile()?
    >
    > I've tried the code below, which is basically copy/paste from the help
    > file. On my Thinkpad this works except the data is stored in os2.ini
    > instead of the file I defined. But on my main system the WPS resets
    > itself when this function is called the first time. After calling a
    > second time, the wps completly hangs.
    >
    > Any ideas?
    >
    > Main system is dual core eCS2.0r2, Thinkpad single core eCS1.2r. I'm
    > calling this code from a xworkplace widget.
    >
    > Thanks in advance,
    > Andi
    >
    > HAB hab = NULLHANDLE; /* Window handle */
    > HINI hini = NULLHANDLE; /* INI file handle */
    > PSZ pszFileName = "MBMon2.INI"; /* Name of profile */
    > BOOL rc = FALSE; /* Return code */
    > PSZ pszAppName = "XMBMon2.widget1"; /* Application name */
    > PSZ pszKeyName = "BINARY_DATA"; /* Data key name */
    > APIRET ret = NO_ERROR; /* API return code */
    > PBYTE pData = NULL; /* Pointer to data buffer */
    > ULONG ulDataSize = 0; /* Size of data to read */
    > INT idx = 0; /* Loop index */
    >
    > hab = WinInitialize( 0 );
    > TRACE1("hab=0x%X", hab);
    > if (!hab)
    > {
    > return;
    > }
    > TRACE("try to PrfOpenProfile");
    > hini = PrfOpenProfile( hab, pszFileName ); /* Open INI file */
    >
    > /* Allocate Memory for binary data to be written and read */
    >
    > TRACE("try to DosAllocMem");



    --
    [Reverse the parts of the e-mail address to reply.]

  2. PrfOpenProfile - WPS reset/hang

    Anyone experienced with PrfOpenProfile()?

    I've tried the code below, which is basically copy/paste from the help file. On
    my Thinkpad this works except the data is stored in os2.ini instead of the file
    I defined. But on my main system the WPS resets itself when this function is
    called the first time. After calling a second time, the wps completly hangs.

    Any ideas?

    Main system is dual core eCS2.0r2, Thinkpad single core eCS1.2r. I'm calling
    this code from a xworkplace widget.

    Thanks in advance,
    Andi

    HAB hab = NULLHANDLE; /* Window handle */
    HINI hini = NULLHANDLE; /* INI file handle */
    PSZ pszFileName = "MBMon2.INI"; /* Name of profile */
    BOOL rc = FALSE; /* Return code */
    PSZ pszAppName = "XMBMon2.widget1"; /* Application name */
    PSZ pszKeyName = "BINARY_DATA"; /* Data key name */
    APIRET ret = NO_ERROR; /* API return code */
    PBYTE pData = NULL; /* Pointer to data buffer */
    ULONG ulDataSize = 0; /* Size of data to read */
    INT idx = 0; /* Loop index */

    hab = WinInitialize( 0 );
    TRACE1("hab=0x%X", hab);
    if (!hab)
    {
    return;
    }
    TRACE("try to PrfOpenProfile");
    hini = PrfOpenProfile( hab, pszFileName ); /* Open INI file */

    /* Allocate Memory for binary data to be written and read */

    TRACE("try to DosAllocMem");

  3. Re: PrfOpenProfile - WPS reset/hang

    Thanks Marty,
    Marty schrieb:
    > Check hini after calling it, and call WinGetLastError if it comes back
    > NULLHANDLE.

    it seemed to crash in PrfOpenProfile(). The TRACE statement afterwards is never
    reached. So checking afterwards did not change anything.

    >
    > Also, as stupid as it sounds, use all CAPITAL letters in the INI file name.

    Sound stupid and is stupid. But now there's really a file created as the docs
    describe it. And my data do not end up in os2.ini on the Thinkpad. And my main
    machine do not crash anymore. Cann't believe that lowercase characters in a
    filename can crash an OS/2 machine. I ever thought this is a stable and matured
    platform I'm working on. Or am I using an 'exoctic' function? Are there other
    functions to store application information?

    Tanks again.

    >
    > Not sure about the WPS reset. There is something more evil afoot there.
    >
    > Andi B. wrote:
    >> Anyone experienced with PrfOpenProfile()?
    >>
    >> I've tried the code below, which is basically copy/paste from the help
    >> file. On my Thinkpad this works except the data is stored in os2.ini
    >> instead of the file I defined. But on my main system the WPS resets
    >> itself when this function is called the first time. After calling a
    >> second time, the wps completly hangs.
    >>
    >> Any ideas?
    >>
    >> Main system is dual core eCS2.0r2, Thinkpad single core eCS1.2r. I'm
    >> calling this code from a xworkplace widget.
    >>
    >> Thanks in advance,
    >> Andi
    >>
    >> HAB hab = NULLHANDLE; /* Window handle */
    >> HINI hini = NULLHANDLE; /* INI file handle */
    >> PSZ pszFileName = "MBMon2.INI"; /* Name of profile */
    >> BOOL rc = FALSE; /* Return code */
    >> PSZ pszAppName = "XMBMon2.widget1"; /* Application
    >> name */
    >> PSZ pszKeyName = "BINARY_DATA"; /* Data key name */
    >> APIRET ret = NO_ERROR; /* API return code */
    >> PBYTE pData = NULL; /* Pointer to data
    >> buffer */
    >> ULONG ulDataSize = 0; /* Size of data to
    >> read */
    >> INT idx = 0; /* Loop
    >> index */
    >>
    >> hab = WinInitialize( 0 );
    >> TRACE1("hab=0x%X", hab);
    >> if (!hab)
    >> {
    >> return; }
    >> TRACE("try to PrfOpenProfile");
    >> hini = PrfOpenProfile( hab, pszFileName ); /* Open INI file */
    >>
    >> /* Allocate Memory for binary data to be written and read */
    >>
    >> TRACE("try to DosAllocMem");

    >
    >


  4. Re: PrfOpenProfile - WPS reset/hang

    On Sun, 25 May 2008 12:33:18 UTC, "Andi B." wrote:

    > > Also, as stupid as it sounds, use all CAPITAL letters in the INI file name.

    > Sound stupid and is stupid. But now there's really a file created as the docs
    > describe it. And my data do not end up in os2.ini on the Thinkpad. And my main
    > machine do not crash anymore. Cann't believe that lowercase characters in a
    > filename can crash an OS/2 machine. I ever thought this is a stable and matured
    > platform I'm working on. Or am I using an 'exoctic' function? Are there other
    > functions to store application information?


    Seems to me something similar to the 8.3 naming convention constraint
    for the DLL file names... Something created to mantain compatibility
    with the old DOS-OS/2 dual boot facility with BOOT.COM.

    It's stupid, indeed.

    Mentore

  5. Re: PrfOpenProfile - WPS reset/hang

    On Sun, 25 May 2008 12:33:18 UTC, "Andi B." wrote:
    > Marty schrieb:
    > >
    > > Also, as stupid as it sounds, use all CAPITAL letters in the INI file name.

    >
    > Sound stupid and is stupid. But now there's really a file created as the docs
    > describe it. And my data do not end up in os2.ini on the Thinkpad. And my main
    > machine do not crash anymore. Cann't believe that lowercase characters in a
    > filename can crash an OS/2 machine. I ever thought this is a stable and matured
    > platform I'm working on. Or am I using an 'exoctic' function? Are there other
    > functions to store application information?


    I think the cause is more complex than mere case. ISTR that some arguments
    passed to the Prf* functions have to be in writable memory (possibly so PM
    can, e.g., uppercase filenames). It's likely that your compiler put the
    filename in a read-only segment because of the way you defined it:
    PSZ pszFileName = "MBMon2.INI";

    If you declared it like this, I doubt you would have had any problems:
    char szFileName[] = "MBMon2.INI";


    --
    == == almost usable email address: Rich AT E-vertise.Com == ==
    __________________________________________________ _________________
    |
    | DragText v3.9 with NLS support
    Rich Walsh | A Distinctly Different Desktop Enhancement
    Ft Myers, FL | http://e-vertise.com/dragtext/
    __________________________________________________ _________________


  6. Re: PrfOpenProfile - WPS reset/hang

    Rich Walsh wrote:
    > On Sun, 25 May 2008 12:33:18 UTC, "Andi B." wrote:
    >
    >>Marty schrieb:
    >>
    >>>Also, as stupid as it sounds, use all CAPITAL letters in the INI file name.

    >>
    >>Sound stupid and is stupid. But now there's really a file created as the docs
    >>describe it. And my data do not end up in os2.ini on the Thinkpad. And my main
    >>machine do not crash anymore. Cann't believe that lowercase characters in a
    >>filename can crash an OS/2 machine. I ever thought this is a stable and matured
    >>platform I'm working on. Or am I using an 'exoctic' function? Are there other
    >>functions to store application information?

    >
    > I think the cause is more complex than mere case. ISTR that some arguments
    > passed to the Prf* functions have to be in writable memory (possibly so PM
    > can, e.g., uppercase filenames). It's likely that your compiler put the
    > filename in a read-only segment because of the way you defined it:
    > PSZ pszFileName = "MBMon2.INI";
    >
    > If you declared it like this, I doubt you would have had any problems:
    > char szFileName[] = "MBMon2.INI";


    Excellent observation, Rich! PSZ is defined as an unsigned char *, with
    no reference to "const". Although I'd like to see the parameter
    characterized as "input/output" to denote that it can be modified by the
    function call, the docs do technically cover this base, if quite
    overtly. I always just attributed it to a weird quirk of the Prf API,
    but your explanation makes much more sense.

    --
    [Reverse the parts of the e-mail address to reply.]

  7. Re: PrfOpenProfile - WPS reset/hang

    Rich Walsh schrieb:
    > On Sun, 25 May 2008 12:33:18 UTC, "Andi B." wrote:
    >> Marty schrieb:
    >>> Also, as stupid as it sounds, use all CAPITAL letters in the INI file name.

    >> Sound stupid and is stupid. But now there's really a file created as the docs
    >> describe it. And my data do not end up in os2.ini on the Thinkpad. And my main
    >> machine do not crash anymore. Cann't believe that lowercase characters in a
    >> filename can crash an OS/2 machine. I ever thought this is a stable and matured
    >> platform I'm working on. Or am I using an 'exoctic' function? Are there other
    >> functions to store application information?

    >
    > I think the cause is more complex than mere case. ISTR that some arguments
    > passed to the Prf* functions have to be in writable memory (possibly so PM
    > can, e.g., uppercase filenames). It's likely that your compiler put the
    > filename in a read-only segment because of the way you defined it:
    > PSZ pszFileName = "MBMon2.INI";
    >
    > If you declared it like this, I doubt you would have had any problems:
    > char szFileName[] = "MBMon2.INI";
    >
    >

    So we found a documentation bug. As I copied the code from PrfWriteProfileXXX
    example in pmX.inf from the os2tk45. I compile with VAC3.65. Funny enough I just
    recognized that the PrfOpenProfile() example is the only one which declares the
    filename as char not PSZ.

    And yes Rich, you are right. Declaring as you suggested and the problems are gone.

    Thanks

+ Reply to Thread