I have a PDM add-in that does extensive renaming and moving of files in the PDM vault. The add-in can be triggered from inside SOLIDWORKS or from Explorer.
I need to check any event like state change/rename…etc are triggered from Solidworks PDM addin or Windows explorer.
Just off the top of my head, without testing, I would take a look at the poCmd.mlParentWnd to see if that can be tied to your explorer window handle or your SW session window handle. If you get a chance to look into this before I do, let us know how that works out.
Edit:
In a quick search, this following code could be added to get the process ID from a window handle.
[DllImport("user32.dll", SetLastError=true)]
static extern uint GetWindowThreadProcessId(IntPtr hWnd, out uint processId);
Then use something like this to check the name
Process.GetProcessById(id).ProcessName
Edit 2:
This approach works

Using Explorer to Hook ChangeState:

Using Solidworks PDM Add-In to Hook ChangeState:

Not sure why it’s showing Idle process but that’s where I ended up.
Also tested within the File → Open dialog of Solidworks and the process name was “SLDWORKS”.
@Prasad290 : I understand your question now!
One line:
System.Diagnostics.Process.GetCurrentProcess().Name
Name is explorer.exe or sldworks.exe depending on where the add-in is loaded.
Thanks @AmenJlili and @BigCrazyAl
Actually I already tried these two ways, But just I want to know is there any API will give you the quick answer to do.
API is not supposed to tell which process it’s loaded on. That’s what System.Diagnostics is for.