@@ -338,6 +338,49 @@ record_getfieldcount(msiobj* record, PyObject* args)
338338 return PyLong_FromLong (MsiRecordGetFieldCount (record -> h ));
339339}
340340
341+ static PyObject *
342+ record_getinteger (msiobj * record , PyObject * args )
343+ {
344+ unsigned int field ;
345+ int status ;
346+
347+ if (!PyArg_ParseTuple (args , "I:GetInteger" , & field ))
348+ return NULL ;
349+ status = MsiRecordGetInteger (record -> h , field );
350+ if (status == MSI_NULL_INTEGER ){
351+ PyErr_SetString (MSIError , "could not convert record field to integer" );
352+ return NULL ;
353+ }
354+ return PyInt_FromLong ((long ) status );
355+ }
356+
357+ static PyObject *
358+ record_getstring (msiobj * record , PyObject * args )
359+ {
360+ unsigned int field ;
361+ unsigned int status ;
362+ char buf [2000 ];
363+ char * res = buf ;
364+ DWORD size = sizeof (buf );
365+ PyObject * string ;
366+
367+ if (!PyArg_ParseTuple (args , "I:GetString" , & field ))
368+ return NULL ;
369+ status = MsiRecordGetString (record -> h , field , res , & size );
370+ if (status == ERROR_MORE_DATA ) {
371+ res = (char * ) malloc (size + 1 );
372+ if (res == NULL )
373+ return PyErr_NoMemory ();
374+ status = MsiRecordGetString (record -> h , field , res , & size );
375+ }
376+ if (status != ERROR_SUCCESS )
377+ return msierror ((int ) status );
378+ string = PyString_FromString (res );
379+ if (buf != res )
380+ free (res );
381+ return string ;
382+ }
383+
341384static PyObject *
342385record_cleardata (msiobj * record , PyObject * args )
343386{
@@ -405,6 +448,10 @@ record_setinteger(msiobj* record, PyObject *args)
405448static PyMethodDef record_methods [] = {
406449 { "GetFieldCount" , (PyCFunction )record_getfieldcount , METH_NOARGS ,
407450 PyDoc_STR ("GetFieldCount() -> int\nWraps MsiRecordGetFieldCount" )},
451+ { "GetInteger" , (PyCFunction )record_getinteger , METH_VARARGS ,
452+ PyDoc_STR ("GetInteger(field) -> int\nWraps MsiRecordGetInteger" )},
453+ { "GetString" , (PyCFunction )record_getstring , METH_VARARGS ,
454+ PyDoc_STR ("GetString(field) -> string\nWraps MsiRecordGetString" )},
408455 { "SetString" , (PyCFunction )record_setstring , METH_VARARGS ,
409456 PyDoc_STR ("SetString(field,str) -> None\nWraps MsiRecordSetString" )},
410457 { "SetStream" , (PyCFunction )record_setstream , METH_VARARGS ,
0 commit comments