Skip to content

data not found…when it is there…

Forums Forums SIMPOL Programming data not found…when it is there…

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #60
    Jim Locker
    Member

    I seem to be unable to post to the newsgroup through my newsreader client. My credentials are not accepted, but I can post from the web. How might I fix that? Anyway, the original text of this message is as follows: In order to get my package to install on multiple versions of Windows, I need to provide a mechanism to permit the database files to be stored in different places, depending on the version of Windows, and I need to have my package able to know about this. Well, the installer handles the storage in different places, so that leaves me only needing to get my package to work. To do this, I have defined a data path variable like this: if sg.platform == “windows” wv =@ getwindowsversion() if wv.MajorVersion < 6: //WinXP or older sg.sStddatapath = "C:Documents and SettingsAll UsersDocumentsThePropertyManager" else: //Win Vista, 7, 8 sg.sStddatapath = "C:UsersPublicPublic DocumentsThePropertyManager" end if On my Windows 2000 virtual machine development system, this works fine. When the program is installed, the database files are placed in the Documents and Settings subdirectory, my program finds the database files, and away we go. On my Windows 7 Professional (32 bit) virtual machine, the installer places the database files in the indicated subdirectory under Users, but when I attempt to open the files, I get an error 7 ("data not found"). My user is an administrator and can directly open the files using simpol personal. As a (possibly related) aside, the program is supposed to check for the existence of a file named etcpaths which exists in the same directory structure as the installed program (Program FilesJust So SoftwareThe Property Manager) and, if that file does not exist, it is to be written. This also works fine on Win2K but the file is not written on Win7...and no error is returned because the program should pop a requester on an error stating the error occurred. The paths file contains path information to all files of various types in the system, providing a mechanism for a user (or for me, for that matter) to rearrange how things are installed should it prove necessary. I suspect a permissions problem, but file I/O to UsersPublic should not be a problem and the "data not found" error is not terribly useful when I know the data is there. Any ideas?

    #1650
    Jim Locker
    Member

    I also will note that this site stripped the backslashes from my message.
    However, you can see where they belong…and they ARE there in the code.

    #1651
    Jim Locker
    Member

    A bit more information.

    I have discovered that, even though browsing with explorer shows my data
    files to be in c:PublicPublic DocumentsThePropertyManager, if I start
    simpol personal and use the requester in simpol personal to browse to that
    subdirectory, simpol personal reports it is opening a file in
    c:PublicDocumentsThePropertyManager.

    If I change the path defined in my program to match this, and run my
    program with normal rights, it continues to report that it fails to find
    files located at c:PublicPublic DocumentsThePropertyManager.

    However, if I change the desktop icon for the program to specify that it
    is to run with administrative privileges, then (after clicking away the
    warning about making changes) the program runs, reporting it is opening
    files located in c:PublicDocumentsThePropertyManager.

    This behavior is simply bizarre and undoubtedly has something to do with
    some Windows policy or another.

    How do I get around this?

    Also, I escaped the backslashes this time, so let us see if they show…

    #1652
    Jim Locker
    Member

    It turns out that if I put the data in c:ProgramDataThePropertyManager
    it works as expected. In Windows 7 anyway. Will it work the same way in
    Vista and in Windows 8?

    What a butt-ugly security model.

    #1653
    Michael
    Keymaster

    Hi Jim,

    Sorry, I have only just seen this. I am unsure about why you couldn't post to the newsgroup via your newsreader, but we will
    hopefully have a forum-style solution in the near future. I will then try and pull the old news group stuff into it in some way,
    or provide some other method of retrieving it.

    I will try and get back to you on this in the next day or so, assuming it is still current.

    Ciao, Neil

    On 26/12/2013 14:15, Jim wrote:
    > I seem to be unable to post to the newsgroup through my newsreader client.
    > My credentials are not accepted, but I can post from the web. How might
    > I fix that?
    >
    > Anyway, the original text of this message is as follows:
    >
    > In order to get my package to install on multiple versions of Windows, I
    > need to provide a mechanism to permit the database files to be stored in
    > different places, depending on the version of Windows, and I need to have
    > my
    > package able to know about this.
    >
    > Well, the installer handles the storage in different places, so that
    > leaves
    > me only needing to get my package to work.
    >
    > To do this, I have defined a data path variable like this:
    >
    > if sg.platform == "windows"
    > wv =@ getwindowsversion()
    > if wv.MajorVersion < 6: //WinXP or older
    > sg.sStddatapath = "C:Documents and SettingsAll
    > UsersDocumentsThePropertyManager"
    > else: //Win Vista, 7, 8
    > sg.sStddatapath = "C:UsersPublicPublic
    > DocumentsThePropertyManager"
    > end if
    >
    > On my Windows 2000 virtual machine development system, this works fine.
    > When the program is installed, the database files are placed in the
    > Documents and Settings subdirectory, my program finds the database files,
    > and away we go.
    >
    > On my Windows 7 Professional (32 bit) virtual machine, the installer
    > places
    > the database files in the indicated subdirectory under Users, but when I
    > attempt to open the files, I get an error 7 ("data not found"). My user
    > is
    > an administrator and can directly open the files using simpol personal.
    >
    > As a (possibly related) aside, the program is supposed to check for the
    > existence of a file named etcpaths which exists in the same directory
    > structure as the installed program (Program FilesJust So SoftwareThe
    > Property Manager) and, if that file does not exist, it is to be written.
    > This also works fine on Win2K but the file is not written on Win7…and no
    > error is returned because the program should pop a requester on an error
    > stating the error occurred. The paths file contains path information to
    > all
    > files of various types in the system, providing a mechanism for a user (or
    > for me, for that matter) to rearrange how things are installed should it
    > prove necessary.
    >
    > I suspect a permissions problem, but file I/O to UsersPublic should not be
    > a problem and the "data not found" error is not terribly useful when I
    > know
    > the data is there.
    >
    > Any ideas?
    >

    #1654
    Michael
    Keymaster

    On 26/12/2013 14:15, Jim wrote:
    > I seem to be unable to post to the newsgroup through my newsreader client.
    > My credentials are not accepted, but I can post from the web. How might
    > I fix that?
    >
    > Anyway, the original text of this message is as follows:
    >
    > In order to get my package to install on multiple versions of Windows, I
    > need to provide a mechanism to permit the database files to be stored in
    > different places, depending on the version of Windows, and I need to have
    > my
    > package able to know about this.

    Sure. I have had to deal with this in a commercial package I wrote in
    SIMPOL a few years back.

    > Well, the installer handles the storage in different places, so that
    > leaves
    > me only needing to get my package to work.

    Yes and no, you should still decide where you want it to go. I will use the
    Windows 7 paths for examples. There are basically two viable targets:

    C:UsersPublic
    C:ProgramData

    Whether you choose the second or the first depends to a large degree on
    whether you want to place the files where the user can easily find them
    (for backups, etc.).

    I then create a subdirectory in the target directory and place my data
    files in there.

    > To do this, I have defined a data path variable like this:
    >
    > if sg.platform == "windows"
    > wv =@ getwindowsversion()
    > if wv.MajorVersion < 6: //WinXP or older
    > sg.sStddatapath = "C:Documents and SettingsAll
    > UsersDocumentsThePropertyManager"
    > else: //Win Vista, 7, 8
    > sg.sStddatapath = "C:UsersPublicPublic
    > DocumentsThePropertyManager"
    > end if

    I use a different approach to you, I have the following function:

    // From registrylibhdr.sma
    constant MAX_PATH 260

    // Windows constants used for API calls //
    constant CSIDL_COMMON_DOCUMENTS 0x002e
    constant SHGFP_TYPE_CURRENT 0

    function getwindowsdatafolder()
    string path
    integer e

    e = 0
    // This should contain the C:UsersPublicDocuments folder on Vista,
    // 7, and 8 and "C:Documents and SettingsAll UsersDocuments" on XP
    path = getwindowsfolder(CSIDL_COMMON_DOCUMENTS, error=e)

    // We want the folder above that
    string fpath, froot, fext, dirsep
    dirsep = getdirectorysepchar()
    fpath = ""; froot= ""; fext = ""
    filenameparse(path, fpath, froot, fext, dirsep)
    path = fpath
    end function path

    function getwindowsfolder(integer folderid, integer error)
    sharedlibrary shell32
    sharedlibraryfunction SHGetFolderPath
    integer e, flags
    string path, params

    e = 0
    shell32 =@ sharedlibrary.new("shell32.dll", error=e)
    if shell32 !@= .nul
    params = "ups32upu32p[+t16(" + .tostr(MAX_PATH, 10) + ")]"
    SHGetFolderPath =@ shell32.findfunction("SHGetFolderPathW",
    "SHGetFolderPath", "u32", params, error=e)
    if SHGetFolderPath !@= .nul
    path = space(MAX_PATH)
    flags = SHGFP_TYPE_CURRENT
    e = SHGetFolderPath.call(0, folderid, 0, flags, path)
    if e != 0
    path = .nul
    error = e
    end if
    end if
    end if
    end function path

    > This also works fine on Win2K but the file is not written on Win7…and no
    > error is returned because the program should pop a requester on an error
    > stating the error occurred. The paths file contains path information to
    > all
    > files of various types in the system, providing a mechanism for a user (or
    > for me, for that matter) to rearrange how things are installed should it
    > prove necessary.
    >
    > I suspect a permissions problem, but file I/O to UsersPublic should not be
    > a problem and the "data not found" error is not terribly useful when I
    > know
    > the data is there.
    >
    > Any ideas?

    There are some nasty things that happen in Windows Vista and later with
    their *new* security model where function calls silently fail. This problem
    still plagues the SIMPOL installer, where registration silently fails when
    with some anti-malware packages.

    Ciao, Neil

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.