Skip to main content

When I call the "SetVolumeMountPoint" function in Kernel32.dll, I get the following error: Error code = 1008: An attempt was made to reference a token that does not exist.  I get this error from any function I call in Kernel32.dll.  However, I can call other Win32 functions from sample code I've seen without a problem.  Any ideas?  (I've included a code snippet here.)

               call WINAPI "SetVolumeMountPointA"
                   using by reference RestoreDrive,
                         by reference VolumeGUID
                   returning
                         dwErrorCode
               end-call

               if  dwErrorCode = zero
                   raise new Win32Exception
               end-if

           catch obj-exception as type Win32Exception
               set str
                   to
                   FatalErrMsg                                 &
                   "HResult = "                                &
                   obj-exception::HResult::ToString()          &
                   ", error code = "                           &
                   obj-exception::NativeErrorCode::ToString()  &
                   ": "                                        &
                   obj-exception::Message

  display str



------------------------------
Dennis Strahan
Principal Software Engineer
Self Registered
Raleigh NC US
------------------------------

When I call the "SetVolumeMountPoint" function in Kernel32.dll, I get the following error: Error code = 1008: An attempt was made to reference a token that does not exist.  I get this error from any function I call in Kernel32.dll.  However, I can call other Win32 functions from sample code I've seen without a problem.  Any ideas?  (I've included a code snippet here.)

               call WINAPI "SetVolumeMountPointA"
                   using by reference RestoreDrive,
                         by reference VolumeGUID
                   returning
                         dwErrorCode
               end-call

               if  dwErrorCode = zero
                   raise new Win32Exception
               end-if

           catch obj-exception as type Win32Exception
               set str
                   to
                   FatalErrMsg                                 &
                   "HResult = "                                &
                   obj-exception::HResult::ToString()          &
                   ", error code = "                           &
                   obj-exception::NativeErrorCode::ToString()  &
                   ": "                                        &
                   obj-exception::Message

  display str



------------------------------
Dennis Strahan
Principal Software Engineer
Self Registered
Raleigh NC US
------------------------------

Hello Dennis,

Do the parameters conform with what the documentations say about SetVolumeMountPointA?

Does RestoreDrive point to a drive or directory on an NTFS file system? The value should end with a backslash, and this drive or directory should be empty.

Did you obtain the volume GUID from using GetVolumeNameForVolumeMountPoint?



------------------------------
Fano R.
Developer/Engineer
Rocket Forum Shared Account
------------------------------

Hello Dennis,

Do the parameters conform with what the documentations say about SetVolumeMountPointA?

Does RestoreDrive point to a drive or directory on an NTFS file system? The value should end with a backslash, and this drive or directory should be empty.

Did you obtain the volume GUID from using GetVolumeNameForVolumeMountPoint?



------------------------------
Fano R.
Developer/Engineer
Rocket Forum Shared Account
------------------------------

Hi Fano,

RestoreDrive points to a drive on an NTFS file system.  As far as the call parameters conforming to SetVolumeMountPointA, I've tried it all the ways I can think of.  What you see in the attached code is the latest.

I've uploaded the COBOL source for the project to give a full and complete view.  I'm not sure what you mean by the drive/directory should be empty.  It isn't.  I wrote the app for the exercise.  I did the same in VB, C++ and C# and it works fine in all of those.

I've tested this one and everything works fine except the call to SetVolumeMountPointA.

Regards,

Dennis



------------------------------
Dennis Strahan
Principal Software Engineer
Self Registered
Raleigh NC US
------------------------------

Hi Fano,

RestoreDrive points to a drive on an NTFS file system.  As far as the call parameters conforming to SetVolumeMountPointA, I've tried it all the ways I can think of.  What you see in the attached code is the latest.

I've uploaded the COBOL source for the project to give a full and complete view.  I'm not sure what you mean by the drive/directory should be empty.  It isn't.  I wrote the app for the exercise.  I did the same in VB, C++ and C# and it works fine in all of those.

I've tested this one and everything works fine except the call to SetVolumeMountPointA.

Regards,

Dennis



------------------------------
Dennis Strahan
Principal Software Engineer
Self Registered
Raleigh NC US
------------------------------

Hi Dennis.

You state the following:

"I get this error from any function I call in Kernel32.dll."

What other functions give you this error?

Can you, for instance, call something simple like GetCurrentDirectoryA?



------------------------------
Chris Glazier
Principal Technical Support Specialist
Rocket Forum Shared Account
------------------------------

Hi Dennis.

You state the following:

"I get this error from any function I call in Kernel32.dll."

What other functions give you this error?

Can you, for instance, call something simple like GetCurrentDirectoryA?



------------------------------
Chris Glazier
Principal Technical Support Specialist
Rocket Forum Shared Account
------------------------------

Calling GetCurrentDirectoryA works!  I suspect functions that perform some kind of update are blocked but I don't know how or why.  Not sure where to take it from here.  Any ideas?



------------------------------
Dennis Strahan
Principal Software Engineer
Self Registered
Raleigh NC US
------------------------------

Calling GetCurrentDirectoryA works!  I suspect functions that perform some kind of update are blocked but I don't know how or why.  Not sure where to take it from here.  Any ideas?



------------------------------
Dennis Strahan
Principal Software Engineer
Self Registered
Raleigh NC US
------------------------------

One thing I did notice on your call is that the RestoreDrive parameter is not actually being null terminated.

It is defined as:
05  RestoreDrive            pic  x(03)  value "X:\\".  

and to set the null you use:
set RestoreDrive        to RestoreDrive         & x"00"

This would be 4 characters long in a 3 character field so the null would be removed.

I am not sure if this has anything to do with the problem but just something I noticed...



------------------------------
Chris Glazier
Principal Technical Support Specialist
Rocket Forum Shared Account
------------------------------