{"id":4610,"date":"2014-03-30T14:00:05","date_gmt":"2014-03-30T14:00:05","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/why-does-shparsedisplayname-give-an-access-violation-if-ive-imported-it-myself-collection-of-common-programming-errors\/"},"modified":"2014-03-30T14:00:05","modified_gmt":"2014-03-30T14:00:05","slug":"why-does-shparsedisplayname-give-an-access-violation-if-ive-imported-it-myself-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/why-does-shparsedisplayname-give-an-access-violation-if-ive-imported-it-myself-collection-of-common-programming-errors\/","title":{"rendered":"Why does SHParseDisplayName give an access violation if I&#39;ve imported it myself?-Collection of common programming errors"},"content":{"rendered":"<p>I get an access violation when trying to get a pidl form a path in Delphi, and the returned pidl is nil. This is my code:<\/p>\n<pre><code>type\n  \/\/ TParseDisplayName = function(pszPath: PChar; pbc: pointer; var pidl: PItemIDList; sfgaoIn: LongWord; var psfgaoOut: LongWord): LongInt;\n  TParseDisplayName = function(pszPath: PWideChar; pbc: IBindCtx; var pidl: PItemIDList; sfgaoIn: ULong; var psfgaoOut: ULong): HResult;\n\nvar\n  SHParseDisplayName: TParseDisplayName;\n  SHELL32DLLHandle : THandle;\n\nprocedure test();\nvar\n  ws : WideString;\n  tmpLongWord: ULong;\n  lpItemID: PItemIDList;\nbegin\n  \/\/ws := 'Mes documents';\n\n  CoInitialize(nil);\n\n  \/\/ path to test\n  ws := 'C:\\inetsdk\\Nouveau Document WordPad.doc';\n\n  if (SHParseDisplayName(PWideChar(ws), nil, lpItemID, 0, tmpLongWord) = S_OK) then\n    if not assigned(lpItemID) then      \n      s := SysErrorMessage(getLastError);\n\n  CoUnInitialize();\nend;\n\ninitialization\n  SHELL32DLLHandle  := LoadLibraryW('shell32.dll');\n\n  @SHParseDisplayName := GetProcAddress(SHELL32DLLHandle, 'SHParseDisplayName');\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>I get an access violation when trying to get a pidl form a path in Delphi, and the returned pidl is nil. This is my code: type \/\/ TParseDisplayName = function(pszPath: PChar; pbc: pointer; var pidl: PItemIDList; sfgaoIn: LongWord; var psfgaoOut: LongWord): LongInt; TParseDisplayName = function(pszPath: PWideChar; pbc: IBindCtx; var pidl: PItemIDList; sfgaoIn: ULong; var [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-4610","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4610","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=4610"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4610\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=4610"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=4610"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=4610"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}