summaryrefslogtreecommitdiff
path: root/ext/win32ole/win32ole_typelib.c
diff options
context:
space:
mode:
authorsuke <suke@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-08-07 12:52:25 +0000
committersuke <suke@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-08-07 12:52:25 +0000
commit707ff7bfb715d7caa7766041cea8bad6e8ca43a0 (patch)
treeb8452a935a16a9b858528d0dc4f14d2b95fe7437 /ext/win32ole/win32ole_typelib.c
parentb618b8685c5d9c2ca8cd7ee016e64222d34a9f05 (diff)
* ext/win32ole/win32ole_typelib.c (foletypelib_version): return
version string. * test/win32ole/test_win32ole_typelib.rb (test_version): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47096 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/win32ole/win32ole_typelib.c')
-rw-r--r--ext/win32ole/win32ole_typelib.c60
1 files changed, 29 insertions, 31 deletions
diff --git a/ext/win32ole/win32ole_typelib.c b/ext/win32ole/win32ole_typelib.c
index 2becbfd..fc164f2 100644
--- a/ext/win32ole/win32ole_typelib.c
+++ b/ext/win32ole/win32ole_typelib.c
@@ -299,34 +299,34 @@ oletypelib_search_registry2(VALUE self, VALUE args)
RegCloseKey(hversion);
} else {
fver = 0.0;
- for(j = 0; ;j++) {
- ver = reg_enum_key(hguid, j);
- if (ver == Qnil)
- break;
- err = reg_open_vkey(hguid, ver, &hversion);
- if (err != ERROR_SUCCESS)
- continue;
- tlib = reg_get_val(hversion, NULL);
- if (tlib == Qnil) {
- RegCloseKey(hversion);
- continue;
- }
- if (fver < atof(StringValuePtr(ver))) {
- fver = atof(StringValuePtr(ver));
- version = ver;
- typelib = tlib;
- }
- RegCloseKey(hversion);
- }
+ for(j = 0; ;j++) {
+ ver = reg_enum_key(hguid, j);
+ if (ver == Qnil)
+ break;
+ err = reg_open_vkey(hguid, ver, &hversion);
+ if (err != ERROR_SUCCESS)
+ continue;
+ tlib = reg_get_val(hversion, NULL);
+ if (tlib == Qnil) {
+ RegCloseKey(hversion);
+ continue;
+ }
+ if (fver < atof(StringValuePtr(ver))) {
+ fver = atof(StringValuePtr(ver));
+ version = ver;
+ typelib = tlib;
+ }
+ RegCloseKey(hversion);
+ }
}
RegCloseKey(hguid);
RegCloseKey(htypelib);
if (typelib != Qnil) {
- hr = oletypelib_from_guid(guid, version, &pTypeLib);
- if (SUCCEEDED(hr)) {
- found = Qtrue;
- oletypelib_set_member(self, pTypeLib);
- }
+ hr = oletypelib_from_guid(guid, version, &pTypeLib);
+ if (SUCCEEDED(hr)) {
+ found = Qtrue;
+ oletypelib_set_member(self, pTypeLib);
+ }
}
return found;
}
@@ -472,27 +472,25 @@ make_version_str(VALUE major, VALUE minor)
/*
* call-seq:
- * WIN32OLE_TYPELIB#version -> The type library version.
+ * WIN32OLE_TYPELIB#version -> The type library version String object.
*
* Returns the type library version.
*
* tlib = WIN32OLE_TYPELIB.new('Microsoft Excel 9.0 Object Library')
- * puts tlib.version #-> 1.3
+ * puts tlib.version #-> "1.3"
*/
static VALUE
foletypelib_version(VALUE self)
{
TLIBATTR *pTLibAttr;
- VALUE major;
- VALUE minor;
ITypeLib *pTypeLib;
+ VALUE version;
pTypeLib = itypelib(self);
oletypelib_get_libattr(pTypeLib, &pTLibAttr);
- major = INT2NUM(pTLibAttr->wMajorVerNum);
- minor = INT2NUM(pTLibAttr->wMinorVerNum);
+ version = rb_sprintf("%d.%d", pTLibAttr->wMajorVerNum, pTLibAttr->wMinorVerNum);
pTypeLib->lpVtbl->ReleaseTLibAttr(pTypeLib, pTLibAttr);
- return rb_Float(make_version_str(major, minor));
+ return version;
}
/*