visual c++ - Transform an operation to generic method -
i working in visual c++, on .net, because need method available on language. want obtain frames per second of video file. best make creating project main() method, in (after debug) see result saving fine in res variable.
void main() { // initialize com library coinitialize(null); // property store video file ipropertystore* store = null; shgetpropertystorefromparsingname(l"c:\\users\\public\\videos\\sample videos\\wildlife.wmv", null, gps_readwrite, __uuidof(ipropertystore), (void**)&store); // frame rate propvariant variant; store->getvalue(pkey_video_framerate, &variant); int res = variant.intval; store->release(); }
now, want create method generic, in order obtain framerate of video. example, if method's name framerate:
char* path = "c:\\users\\public\\videos\\sample videos\\wildlife.wmv"; int fps = framerate(path);
thanks
does not work?
int getframerate(std::wstring path) { // initialize com library coinitialize(null); // property store video file ipropertystore* store = null; shgetpropertystorefromparsingname(path.c_str(), null, gps_readwrite, __uuidof(ipropertystore), (void**)&store); // frame rate propvariant variant; store->getvalue(pkey_video_framerate, &variant); int res = variant.intval; store->release(); return res; }
the assumption here shgetpropertystorefromparsingname takes string first parameter. in c++ recommend staying away char*, std::string preferable in situations. difficulty see making sure path
correct type.
Comments
Post a Comment