- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am trying to decifer a safearray passed from visualbasic. I can access bounds, individual elements, use a pointer to access arrays "in place" but I cannot seem to get SafeArrayGetVarType to work. The compiler complains fwhen I try to use SafeArrayGet VarType:
...
integer(int_ptr_kind()), intent(inout) :: VBArray
Integer iRes, iType
...
iRes = SafeArrayGetVarType(VBArray, iType)
error #6404: This name does not have a type, and must have an explicit type. [SAFEARRAYGETVARTYPE]
it also errors out if I skip assigning the result to iRes adn just "call it" instead. I have attached the full routine. Any help would be appreciated.
Thanks,
Rick
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You can write your own interface for that function easily enough. It would probably look like this:
interface
function SafeArrayGetVarType (array, vt) bind(C,name="SafeArrayGetVarType")
!DIR$ ATTRIBUTES STDCALL :: SafeArrayGetVarType
use IFWINTY
integer(HANDLE) :: SafeArrayGetVarType
type(*), intent(in) :: array
integer(SHORT), intent(out) :: vt
end function SafeArrayGetVarType
end interface
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
There is a SafeArrays sample in the Samples Bundle, under compiler_f\MixedLanguages. However, no routine named SafeArrayGetVarType is defined (in module OLEAUT32). I see that Microsoft does define such a routine, with an output argument of VARTYPE, but it seems related to variant types. It does seem that the returned type is not a simple integer. It would take some research to see just what this was and how to use it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have not played with this enough to get arrays or complex results that seem available in other methods, but with an array of doubles such returns 5, the underlying datatype:
#include "oaidl.h"
// returns data type in array
extern "C" DCPP_API long VTSafeArray(SAFEARRAY * *psaArray) {
int iVT;
VARTYPE VT; //short
HRESULT hRes = SafeArrayGetVartype(*psaArray, &VT);
iVT = (int)VT;
return iVT;
}
// https://docs.microsoft.com/en-us/previous-versions/windows/embedded/ms897140(v=msdn.10)
// https://docs.microsoft.com/en-us/windows/win32/api/oleauto/nf-oleauto-safearraygetvartype
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You can write your own interface for that function easily enough. It would probably look like this:
interface
function SafeArrayGetVarType (array, vt) bind(C,name="SafeArrayGetVarType")
!DIR$ ATTRIBUTES STDCALL :: SafeArrayGetVarType
use IFWINTY
integer(HANDLE) :: SafeArrayGetVarType
type(*), intent(in) :: array
integer(SHORT), intent(out) :: vt
end function SafeArrayGetVarType
end interface
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page